【问题标题】:Cannot use GDAL with Python 3.3 or 3.4 in Conda无法在 Conda 中将 GDAL 与 Python 3.3 或 3.4 一起使用
【发布时间】:2017-07-26 16:11:24
【问题描述】:

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

【问题讨论】:

  • 你能试试conda install -n py34 gdal icu=56.* -c conda-forge吗?
  • 以下对我有用(我的频道中已经有conda-forge):conda create -n gdal python=3.4 gdal icu=56.*
  • 不幸的是,我收到与您建议的命令相同的错误!

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


【解决方案1】:

从问题到答案的移动解决方案:

编辑:问题解决了!

解决方案在以下线程中: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

希望降级不会影响其他软件包!

【讨论】:

  • 相同的解决方案(降级 jpeg)也适用于 Python 2.7.13
猜你喜欢
  • 1970-01-01
  • 2019-05-06
  • 2014-10-17
  • 2015-06-22
  • 1970-01-01
  • 2014-10-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多