不能在Conda中使用Python 3.3和3.3或3.4

时间:2017-07-26 16:11:24

标签: python python-2.7 python-3.x conda gdal

我拼命想让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

1 个答案:

答案 0 :(得分:2)

将解决方案从问题转移到答案:

  编辑:问题解决了!

     

解决方案在以下主题中:Issue when imoporting GDAL : ImportError, Library not loaded, Image not found

     

将conda-forge添加到我的.condarc后,我做了:

$ conda create -n TEST_GDAL python=3.4 gdal
$ conda install -n TEST_GDAL -f jpeg=8
$ conda install -n TEST_GDAL libgdal
     

降级了一些软件包并安装了GDAL 2.2.1

     

希望降级不会影响其他套餐!