El miércoles, 12 de octubre de 2022 a las 10:18:23 UTC-3, Abdul Haseeb Azizi
escribió:
> On Wednesday, October 12, 2022 at 9:51:22 AM UTC+2, Abdul Haseeb Azizi wrote:
> > On Tuesday, October 11, 2022 at 10:29:34 PM UTC+2, MRAB wrote:
> > > On 2022-10-11 20:38, Thomas Passin wrote:
> > > > On Windows, when I tried to install gdal using pip, it needed to
> > > > compile
> > > > part of it. I'm not set up with the Microsoft compiler and header
> > > > files, so that failed. If you are on Windows, you will need to look for
> > > > a binary wheel to install, or install and configure the compiler and
> > > > header files.
> > > >
> > > The PyPI page at https://pypi.org/project/GDAL/ has this:
> > >
> > > """
> > > Conda
> > > GDAL can be quite complex to build and install, particularly on Windows
> > > and MacOS. Pre built binaries are provided for the conda system:
> > >
> > > https://docs.conda.io/en/latest/
> > >
> > > By the conda-forge project:
> > >
> > > https://conda-forge.org/
> > > """
> > >
> > > > On 10/11/2022 11:53 AM, Abdul Haseeb Azizi wrote:
> > > >> Hi everyone,
> > > >> I am new to python and I am trying to utilize this code "from osgeo
> > > >> import gdal". I installed python 3.10 and also I installed anaconda3
> > > >> to solve this matter but I could not succeed. When I run that code I
> > > >> get the following error.
> > > >> ---
> > > >>
> > > >> ModuleNotFoundError Traceback (most recent call last)
> > > >> Cell In [1], line 1
> > > >> > 1 from osgeo import gdal
> > > >>
> > > >> ModuleNotFoundError: No module named 'osgeo'
> > > >>
> > > >> I also tried to create anaconda environment and enter the following
> > > >> codes:
> > > >> conda crate --name pygdal
> > > >> conda activate pygdal
> > > >> conda install -c conda-forge gdal
> > > >>
> > > >> I don't what is the problem. Any help is appreciated to solve this
> > > >> matter.
> > > >> Looking forward to hear from you.
> > > >>
> > > >> with regards
> > > >> Abdul
> > > >
> > Thanks a lot for your recommendations.
> > As I mentioned before I installed conda and also created conda environment
> > using the following codes:
> > Step 1: Create conda environment
> >
> > conda create --name venv
> >
> > After creating the virtual environment, by default it will install some of
> > the packages.
> > Step 2: Installation of gdal
> > conda install -c conda-forge gdal
> > Step 3: Installation of ipykernel
> >
> > conda install -c anaconda ipykernel
> >
> > Step 4: Add ipykernel and run jupyternotebook
> >
> > python -m ipykernel install --user --name=venv
> > jupyter notebook
> >
> >
> > still I get the following error:
> >
> > %pip install gdal
> >
> > Requirement already satisfied: gdal in
> > c:\users\abdul\anaconda3\lib\site-packages (3.4.1)
> > Note: you may need to restart the kernel to use updated packages.
> >
> > from osgeo import gdal
> >
> >
> > ---
> > ImportError Traceback (most recent call last)
> > File ~\anaconda3\lib\site-packages\osgeo\__init__.py:29, in
> > swig_import_helper()
> > 28 try:
> > ---> 29 return importlib.import_module(mname)
> > 30 except ImportError:
> >
> > File ~\anaconda3\lib\importlib\__init__.py:127, in import_module(name,
> > package)
> > 126 level += 1
> > --> 127 return _bootstrap._gcd_import(name[level:], package, level)
> >
> > File :1030, in _gcd_import(name, package,
> > level)
> >
> > File :1007, in _find_and_load(name, import_)
> >
> > File :986, in _find_and_load_unlocked(name,
> > import_)
> >
> > File :666, in _load_unlocked(spec)
> >
> > File :565, in module_from_spec(spec)
> >
> > File :1173, in create_module(self,
> > spec)
> >
> > File :228, in _call_with_frames_removed(f,
> > *args, **kwds)
> >
> > ImportError: DLL load failed while importing _gdal: The specified module
> > could not be found.
> >
> > During handling of the above exception, another exception occurred:
> >
> > ImportError Traceback (most recent call last)
> > Input In [1], in ()
> > > 1 from osgeo import gdal
> > File ~\anaconda3\lib\site-packages\osgeo\__init__.py:45, in
> > 41 raise ImportError(traceback_string + '\n' + msg)
> > 42 return importlib.import_module('_gdal')
> > ---> 45 _gdal = swig_import_helper()
> > 46 del swig_import_helper
> > 48 __version__ = _gdal.__version__ = _gdal.VersionInfo("RELEASE_NAME")
> >
> > File ~\anaconda3\lib\site-packages\osgeo\__init__.py:41, in
> > swig_import_helper()
> > 39 import traceback
> > 40 traceback_string = ''.join(traceback.format_exception(*sys.exc_info()))
> > ---> 41 raise ImportError(traceback_string + '\n' + msg)
> > 42 return importlib.import_module('_gdal')
> >
> > ImportError: Traceback (most recent call last):
> > File "C:\Users\abdul\anaconda3\lib\site-packages\osgeo\__init_