无法在 Conda 中将 GDAL 与 Python 3.3 或 3.4 一起使用
Cannot use GDAL with Python 3.3 or 3.4 in Conda
我拼命想让 GDAL 在我的 Python 3.4 Conda 环境中工作,但是我收到了一个错误。我尝试使用 Python 2.7、3.3、3.4 和 3.6 安装 GDAL 来测试,GDAL 只能在 2.7 和 3.6 中工作。
我 运行正在使用 Debian 8.8 Jessie 并升级了我的 Conda。
以下是我遵循的步骤:
$ conda create -n py34 python=3.4
$ conda install -n py34 gdal -c conda-forge
为了测试,我会做:
$ source activate py34
$ python -c 'import gdal'
完成 Python 2.7 和 3.6 后,它可以正常工作。但是,由于与其他库的兼容性,我需要在 3.4 环境中 运行 GDAL。
对于 Python 3.3(以防万一它有用)我得到:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/username/anaconda3/envs/py33/lib/python3.3/site-packages/gdal.py", line 2, in <module>
from osgeo.gdal import deprecation_warn
File "/home/username/anaconda3/envs/py33/lib/python3.3/site-packages/osgeo/__init__.py", line 21, in <module>
_gdal = swig_import_helper()
File "/home/username/anaconda3/envs/py33/lib/python3.3/site-packages/osgeo/__init__.py", line 17, in swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
File "/home/username/anaconda3/envs/py33/lib/python3.3/imp.py", line 188, in load_module
return load_dynamic(name, filename, file)
ImportError: libcom_err.so.3: cannot open shared object file: No such file or directory
Python 3.4 也类似:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/username/anaconda3/envs/py34/lib/python3.4/site-packages/gdal.py", line 2, in <module>
from osgeo.gdal import deprecation_warn
File "/home/username/anaconda3/envs/py34/lib/python3.4/site-packages/osgeo/__init__.py", line 21, in <module>
_gdal = swig_import_helper()
File "/home/username/anaconda3/envs/py34/lib/python3.4/site-packages/osgeo/__init__.py", line 17, in swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
File "/home/username/anaconda3/envs/py34/lib/python3.4/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
ImportError: libicui18n.so.56: cannot open shared object file: No such file or directory
将解决方案从问题移至答案:
EDIT: problem solved!
The solution was in the following thread: Issue when imoporting GDAL : ImportError, Library not loaded, Image not found
After adding the conda-forge to my .condarc, I did:
$ conda create -n TEST_GDAL python=3.4 gdal
$ conda install -n TEST_GDAL -f jpeg=8
$ conda install -n TEST_GDAL libgdal
which downgraded some packages and installed GDAL 2.2.1
Hopefully, the downgrade won't interfere with other packages!
我拼命想让 GDAL 在我的 Python 3.4 Conda 环境中工作,但是我收到了一个错误。我尝试使用 Python 2.7、3.3、3.4 和 3.6 安装 GDAL 来测试,GDAL 只能在 2.7 和 3.6 中工作。 我 运行正在使用 Debian 8.8 Jessie 并升级了我的 Conda。
以下是我遵循的步骤:
$ conda create -n py34 python=3.4
$ conda install -n py34 gdal -c conda-forge
为了测试,我会做:
$ source activate py34
$ python -c 'import gdal'
完成 Python 2.7 和 3.6 后,它可以正常工作。但是,由于与其他库的兼容性,我需要在 3.4 环境中 运行 GDAL。
对于 Python 3.3(以防万一它有用)我得到:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/username/anaconda3/envs/py33/lib/python3.3/site-packages/gdal.py", line 2, in <module>
from osgeo.gdal import deprecation_warn
File "/home/username/anaconda3/envs/py33/lib/python3.3/site-packages/osgeo/__init__.py", line 21, in <module>
_gdal = swig_import_helper()
File "/home/username/anaconda3/envs/py33/lib/python3.3/site-packages/osgeo/__init__.py", line 17, in swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
File "/home/username/anaconda3/envs/py33/lib/python3.3/imp.py", line 188, in load_module
return load_dynamic(name, filename, file)
ImportError: libcom_err.so.3: cannot open shared object file: No such file or directory
Python 3.4 也类似:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/username/anaconda3/envs/py34/lib/python3.4/site-packages/gdal.py", line 2, in <module>
from osgeo.gdal import deprecation_warn
File "/home/username/anaconda3/envs/py34/lib/python3.4/site-packages/osgeo/__init__.py", line 21, in <module>
_gdal = swig_import_helper()
File "/home/username/anaconda3/envs/py34/lib/python3.4/site-packages/osgeo/__init__.py", line 17, in swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
File "/home/username/anaconda3/envs/py34/lib/python3.4/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
ImportError: libicui18n.so.56: cannot open shared object file: No such file or directory
将解决方案从问题移至答案:
EDIT: problem solved!
The solution was in the following thread: Issue when imoporting GDAL : ImportError, Library not loaded, Image not found
After adding the conda-forge to my .condarc, I did:
$ conda create -n TEST_GDAL python=3.4 gdal $ conda install -n TEST_GDAL -f jpeg=8 $ conda install -n TEST_GDAL libgdal
which downgraded some packages and installed GDAL 2.2.1
Hopefully, the downgrade won't interfere with other packages!