admin 管理员组

文章数量: 1086019

I have installed gdal at Anaconda base prompt using "conda install -c conda-fe gdal" and also created separate conda environment (geo) and installed at this location using the same command. I requested gdal version and also from python prompt entered "from osgeo import gdal" and received no errors from either the base or geo environs.

I opened up Spyder from the Anaconda Navigator and added paths to C:\Users\users\anaconda3\Lib and also C:\Users\users\anaconda3\envs\geo\Lib. When I attempt to run python code in Spyder with "import gdal" I receive "ModuleNotFoundError: No module named gdal". I used "from osgeo import gdal" instead of "import gdal" as suggested by others and did not get any errors but code does not seem to recognize gdal commands. After internet search I cannot find anything else to do. Maybe other Spyder settings? Any suggestions would be appreciated. Thanks. Using: Windows 11 Python 3.12 Conda 25.3.0 gdal 3.6.2 Spyder 5.5.1

I have installed gdal at Anaconda base prompt using "conda install -c conda-fe gdal" and also created separate conda environment (geo) and installed at this location using the same command. I requested gdal version and also from python prompt entered "from osgeo import gdal" and received no errors from either the base or geo environs.

I opened up Spyder from the Anaconda Navigator and added paths to C:\Users\users\anaconda3\Lib and also C:\Users\users\anaconda3\envs\geo\Lib. When I attempt to run python code in Spyder with "import gdal" I receive "ModuleNotFoundError: No module named gdal". I used "from osgeo import gdal" instead of "import gdal" as suggested by others and did not get any errors but code does not seem to recognize gdal commands. After internet search I cannot find anything else to do. Maybe other Spyder settings? Any suggestions would be appreciated. Thanks. Using: Windows 11 Python 3.12 Conda 25.3.0 gdal 3.6.2 Spyder 5.5.1

Share Improve this question asked Mar 28 at 13:13 RathprRathpr 35 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The above method did work and the key was to use "from osgeo import gdal" instead of "import gdal". The gdal code that I copied from elsewhere had errors. When I corrected the code it worked.

本文标签: Anaconda Spyder will not import gdalStack Overflow