简体   繁体   中英

ImportError when Installing GDAL for Python 3.6

I am trying to install the GDAL library for my Anaconda Python 3.6. The conda install gdal command is usually the best way of making this work in the past, but it hasn't been updated for the new version of Python. That leaves me with pip install and building from source. I have done this both ways, but I still have the same error message when I do this:

>>> import gdal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/anaconda3/lib/python3.6/site-packages/GDAL-2.2.0-py3.6-linux-x86_64.egg/gdal.py", line 2, in <module>
from osgeo.gdal import deprecation_warn
  File "/home/user/anaconda3/lib/python3.6/site-packages/GDAL-2.2.0-py3.6-linux-x86_64.egg/osgeo/__init__.py", line 21, in <module>
_gdal = swig_import_helper()
  File "/home/user/anaconda3/lib/python3.6/site-packages/GDAL-2.2.0-py3.6-linux-x86_64.egg/osgeo/__init__.py", line 17, in swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
  File "/home/user/anaconda3/lib/python3.6/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
  File "/home/user/anaconda3/lib/python3.6/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /usr/local/lib/libgdal.so.20: undefined symbol: sqlite3_column_table_name

I have Ubuntu 16.04. I have searched online extensively to find a solution, but none of these methods have worked for me. Any thoughts?

If you haven't already, I suggest upgrading conda. I was having the same problem, both on my local machine's Mac OS and in my Docker container's Debian, and upgrading to 4.3.30 fixed it for both.

You have to call from osgeo import gdal

it even says in your error import gdal is depreciated.

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