2014-03-12 21 views
8

我得到在Heroku以下錯誤:的Heroku/Django的:不能導入用戶定義GEOMETRY_BACKEND「GEOS」

django.core.exceptions.ImproperlyConfigured: Could not import user-defined GEOMETRY_BACKEND "geos". 

這很奇怪,因爲它是之前的工作。

我將buildpack設置爲https://github.com/dulaccc/heroku-buildpack-geodjango/

在我的settings.py,我有:

GEOS_LIBRARY_PATH = environ.get('GEOS_LIBRARY_PATH') 
GDAL_LIBRARY_PATH = environ.get('GDAL_LIBRARY_PATH') 

當我部署到Heroku的,似乎在尋找GEOS。這裏的日誌:

-----> Checking for GEOS 
    Installed 
    GEOS installed and accessible with env variable 'GEOS_LIBRARY_PATH' 
-----> Checking for Proj.4 
    Installed 
    Proj.4 installed and accessible with env variable 'PROJ4_LIBRARY_PATH' 
-----> Checking for GDAL 
    Installed 
    GDAL installed and accessible with env variable 'GDAL_LIBRARY_PATH' 

回答

0

我只是碰到了完全相同的錯誤,但我使用從ddollar https://github.com/ddollar/heroku-buildpack-multi多buildpack方法已經可以正常使用,直到今天早上。

$ heroku config:set BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git 
$ cat .buildpacks 

# .buildpacks 
https://github.com/cyberdelia/heroku-geo-buildpack.git 
https://github.com/heroku/heroku-buildpack-python 

正如你所說,它似乎找到/安裝geos和gdal庫,但django沒有。這是因爲Django的要完整路徑按照文檔:

https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/geolibs/

所以在我的情況下,我加入到我的settings.py如下:

GEOS_LIBRARY_PATH = "{}/libgeos_c.so".format(environ.get('GEOS_LIBRARY_PATH')) 
GDAL_LIBRARY_PATH = "{}/libgdal.so".format(environ.get('GDAL_LIBRARY_PATH')) 

現在是所有好如初。

1

此錯誤是由於安裝目錄路徑不正確。 heroku-geo-buildpack的這個分支在他們的最新提交中糾正了這個問題。

https://github.com/Tekco/heroku-geo-buildpack

+0

謝謝你的鏈接!另一天,我又救了我一個腦袋在牆上猛撲過來 – Neara