【发布时间】:2015-01-16 01:18:45
【问题描述】:
我正在使用 python 3.4、postgres 9.3.5、Windows 7。
我按照这个来尝试让 GeoDjango 工作: https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#windows
当我尝试将 django.contrib.gis 添加到已安装的应用程序(在 pycharm 中),或者当我尝试运行时
以下是回溯。
但是,在这个目录中 C:\Python34\Lib\site-packages\django\contrib\gis\geos 有geometry.py(其中包含GEOSGeometry 类)和error.py(其中包含GEOSException 类)。
当我在 python shell 中运行它时,它不会抛出任何错误:
>>> from django.contrib.gis.geos.error import GEOSException
感谢您对问题可能存在的任何想法。 一堆其他的回溯,然后:
File "C:\Python34\lib\site-packages\django\contrib\gis\forms\fields.py", line
8, in <module>
from django.contrib.gis.geos import GEOSException, GEOSGeometry
ImportError: cannot import name 'GEOSException'
更新 我发现了一些建议我应该更新项目设置的信息:
GEOS_LIBRARY_PATH = r'C:\Program Files\OSGeo4W64\bin\geos_c.dll'
这行得通,但现在我收到 WinError 126
File "C:\Python34\lib\site-packages\django\contrib\gis\forms\fields.py", line
8, in <module>
from django.contrib.gis.geos import GEOSException, GEOSGeometry
File "C:\Python34\lib\site-packages\django\contrib\gis\geos\__init__.py", line
9, in <module>
from .libgeos import geos_version, geos_version_info # NOQA: flake8 detects
only the last __all__
File "C:\Python34\lib\site-packages\django\contrib\gis\geos\libgeos.py", line
61, in <module>
lgeos = CDLL(lib_path)
File "C:\Python34\lib\ctypes\__init__.py", line 351, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
我不清楚是什么模块找不到,也不知道如何修复它。
【问题讨论】:
标签: python django postgresql geodjango