python 在 django 下找不到以其他方式找到的库

发布于 2024-12-05 12:35:46 字数 1192 浏览 1 评论 0原文

我刚刚成功安装了 GeoDjango 和所有必需的库。我已经设置了环境变量和注册表项(是的,在 Windows 下工作),并且一切都可以从命令行找到。

d:\...\> python
>>> from django.contrib.gis.geos import *
>>> exit()
d:\...\> python manage.py runserver 0.0.0.0
(...)

现在,当在这里运行的服务器遇到它应该执行的同一行代码时,它会说

WindowsError at /NT/BUAConvex/4DED02804:SQLEXPRESS:44_EU_2011Q2/20187417/
[Error 126] The specified module could not be found

D:\...\views.py in <module>
from django.contrib.gis.geos import * ...

c:\python27\lib\site-packages\django\contrib\gis\geos\__init__.py in <module>
from django.contrib.gis.geos.geometry import GEOSGeometry, wkt_regex, hex_regex ...

c:\python27\lib\site-packages\django\contrib\gis\geos\geometry.py in <module>
from django.contrib.gis.geos.coordseq import GEOSCoordSeq ...

c:\python27\lib\site-packages\django\contrib\gis\geos\coordseq.py in <module>
from django.contrib.gis.geos.libgeos import CS_PTR ...

c:\python27\lib\site-packages\django\contrib\gis\geos\libgeos.py in <module>
lgeos = CDLL(lib_path) ...

c:\python27\lib\ctypes\__init__.py in __init__
            self._handle = _dlopen(self._name, mode) ...

I've just successfully installed GeoDjango and all the required libraries. I've set the environment variables and registry keys (yea working under Windows here) and everything works find from the command line.

d:\...\> python
>>> from django.contrib.gis.geos import *
>>> exit()
d:\...\> python manage.py runserver 0.0.0.0
(...)

Now when the server that's being run here encounters the very same line in code it's supposed to execute, it says

WindowsError at /NT/BUAConvex/4DED02804:SQLEXPRESS:44_EU_2011Q2/20187417/
[Error 126] The specified module could not be found

D:\...\views.py in <module>
from django.contrib.gis.geos import * ...

c:\python27\lib\site-packages\django\contrib\gis\geos\__init__.py in <module>
from django.contrib.gis.geos.geometry import GEOSGeometry, wkt_regex, hex_regex ...

c:\python27\lib\site-packages\django\contrib\gis\geos\geometry.py in <module>
from django.contrib.gis.geos.coordseq import GEOSCoordSeq ...

c:\python27\lib\site-packages\django\contrib\gis\geos\coordseq.py in <module>
from django.contrib.gis.geos.libgeos import CS_PTR ...

c:\python27\lib\site-packages\django\contrib\gis\geos\libgeos.py in <module>
lgeos = CDLL(lib_path) ...

c:\python27\lib\ctypes\__init__.py in __init__
            self._handle = _dlopen(self._name, mode) ...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

早茶月光 2024-12-12 12:35:46

感谢@ed。和@gddc我找到了解决方案。 Django shell 中也出现了问题。结果我在 Django 设置中设置了 GEOS_LIBRARY_PATH = 'c:\OSGeo4W' ,它应该是 'c:\OSGeo4W\bin' 。调用普通 Python 会忽略这些设置,而是依赖操作系统自身的功能来查找 .dll(成功)。

Thanks to @ed. and @g.d.d.c I found the solution. Problem turned up in the Django shell as well. Turns out I had set GEOS_LIBRARY_PATH = 'c:\OSGeo4W' in my Django settings where it should've been 'c:\OSGeo4W\bin'. Calling plain Python ignored those settings and instead relied on the OS-own functionality to find the .dll (which succeeds).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文