【问题标题】:Geodjango Exception when importing django.contrib.gis.gdal: OSError: /usr/lib/libgdal.so.1: undefined symbol: sqlite3_column_table_name导入 django.contrib.gis.gdal 时出现 Geodjango 异常:OSError: /usr/lib/libgdal.so.1: undefined symbol: sqlite3_column_table_name
【发布时间】:2017-05-22 03:40:51
【问题描述】:

我已按照tutorial 在我的 Ubuntu 14.04 上安装 Geodjango。我正在使用 Django 1.10 和 Python 3.5、postgres-9.6 和 postgis 2.3。

我检查了herehere,但没有找到解决办法。 在新安装的 ubuntu 14.04 虚拟机中,它可以工作。

但是在我的安装中,当我尝试进行迁移时,我得到了: OSError: /usr/lib/libgdal.so.1: undefined symbol: sqlite3_column_table_name

进一步调查,我简单地尝试了:

from django.contrib.gis import gdal

得到:

Traceback (most recent call last):   
File "<stdin>", line 1, in <module>   
File "/home/pv/anaconda3/envs/dj110py35/lib/python3.5/site-packages/django/contrib/gis/gdal/__init__.py", line 49, in <module>
    from django.contrib.gis.gdal.driver import Driver  # NOQA   
File "/home/pv/anaconda3/envs/dj110py35/lib/python3.5/site-packages/django/contrib/gis/gdal/driver.py", line 5, in <module>
    from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi   
File "/home/pv/anaconda3/envs/dj110py35/lib/python3.5/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 9, in <module>
    from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal   
File "/home/pv/anaconda3/envs/dj110py35/lib/python3.5/site-packages/django/contrib/gis/gdal/libgdal.py", line 48, in <module>
    lgdal = CDLL(lib_path)   
File "/home/pv/anaconda3/envs/dj110py35/lib/python3.5/ctypes/__init__.py", line 347, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /usr/lib/libgdal.so.1: undefined symbol: sqlite3_column_table_name

关于如何修复我的设置有什么建议吗?

更新

这似乎是我的 conda 环境的问题。当我开始使用 pip virtualenv 时,问题不再出现。我没有回答这个问题,因为我找不到解决方案,只有一种解决方法。但是用 pip virtualenv 重建环境是可行的

【问题讨论】:

    标签: postgresql postgis conda geodjango


    【解决方案1】:

    在conda环境中:conda install -c conda-forge gdal=2.2.1

    在 django settings.py 中: GDAL_LIBRARY_PATH = '&lt;HOME&gt;/anaconda3/envs/&lt;env_name&gt;/lib/libgdal.so'

    【讨论】:

    • 当我运行命令时出现错误:Fetching package metadata ............. PackageNotFoundError: Packages missing in current channels: - gdal 2.2.1
    【解决方案2】:

    我也遇到了这个问题,并且指定

    GDAL_LIBRARY_PATH = <HOME>/anaconda3/envs/<env_name>/lib/libgdal.so
    

    (在project.settingsos.environ.setdefault)导致

    libicui18n.so.56: cannot open shared object file: No such file or directory. 
    

    对我有用的解决方法是升级 icu:

    conda install -c conda-forge icu=58
    

    升级 icu 也会导致其他软件包版本发生一些变化(qt 从5.6.2-4 降级到5.6.2-3,其余升级)。

    【讨论】:

      【解决方案3】:

      我只是在我的 conda 环境下运行:

      conda install gdal
      

      Guy de Carufel's solution 对我不起作用,尽管他指出了正确的方向,谢谢

      【讨论】:

        【解决方案4】:

        您是否从源代码构建 SQLite?然后,您忘记启用列元数据。用

        重新编译SQLite
        CFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA=1" ./configure
        make
        sudo make install
        

        享受使用尖端 SQLite 的乐趣。

        参考 - https://www.sqlite.org/compile.html#enable_column_metadata

        【讨论】:

          猜你喜欢
          • 2018-10-01
          • 2020-04-06
          • 1970-01-01
          • 1970-01-01
          • 2018-06-18
          • 2014-04-12
          • 2014-02-26
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多