简体   繁体   中英

Pycharm cannot import GDAL from conda environment on another computer

I have created a Python 3.4 conda environment and install GDAL via conda-forge channel on both computers and works perfectly on one computer but not for the other computer, where it only works when activating from the command line. (The problem comes from transferring the pycharm project)

In both cases I always point to the corresponding project interpreter first, where all packages are shown including GDAL. However, although I can import the rest of the packages, import gdal on the second computer returns:

File "C:\\Users\\burbujas\\AppData\\Local\\Continuum\\Anaconda3\\envs\\py34\\lib\\site-packages\\osgeo__init__.py", line 21, in swig_import_helper _mod = imp.load_module('_gdal', fp, pathname, description)`

File "C:\\Users\\burbujas\\AppData\\Local\\Continuum\\Anaconda3\\envs\\py34\\lib\\imp.py", line 243, in load_module return load_dynamic(name, filename, file)`

ImportError: DLL load failed: The specified module could not be found.`

I don't remember which computer was used to initialize the project, probably the first one.

Any hint will be appreciated.

There is something here. Although I cannot apply it. https://github.com/conda-forge/gdal-feedstock/issues/111

In more detail: Re-declare the PATH in the Configuration-Section (Run/Debug-Configurations) where prefix is the PATH to the wanted conda-env: prefix;prefix\\Library\\mingw-w64\\bin;prefix\\Library\\usr\\bin;prefix \\Library\\bin (path's according to my win 7 machine, YMMV) add GDAL_DATA pointing to prefix \\Library\\share\\gdal

In PyCharm you can do that going to Settings. Then Project interpreter. Click on the arrow down and then show all. On the right the last option will be Show path for the interpreter. Add library/share/gdal

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM