最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Anaconda Spyder will not import gdal - Stack Overflow

programmeradmin1浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论