GeoDjango GEOSException 오류
내 컴퓨터에 GeoDjango를 설치하려고합니다. 저는 Python을 처음 접했고 다른 팀원들에게 매우 까다로운 설치 프로젝트에 참여하고 있습니다. brew를 사용하여 Python 2.7 및 GEOS를 설치하고 PSQL 9.2.4를 실행했지만 웹 서버를 실행하려고하면이 오류가 계속 발생합니다.
__import__(name)
File "/Users/armynante/Desktop/uclass-files/uclass-env/lib/python2.7/site
packages/django/contrib/gis/geometry/backend/geos.py", line 1, in <module>
from django.contrib.gis.geos import (
File "/Users/armynante/Desktop/uclass-files/uclass-env/lib/python2.7/site
packages/django/contrib/gis/geos/__init__.py", line 6, in <module>
from django.contrib.gis.geos.geometry import GEOSGeometry, wkt_regex, hex_regex
File "/Users/armynante/Desktop/uclass-files/uclass-env/lib/python2.7/site
packages/django/contrib/gis/geos/geometry.py", line 14, in <module>
from django.contrib.gis.geos.coordseq import GEOSCoordSeq
File "/Users/armynante/Desktop/uclass-files/uclass-env/lib/python2.7/site-
packages/django/contrib/gis/geos/coordseq.py", line 9, in <module>
from django.contrib.gis.geos.libgeos import CS_PTR
File "/Users/armynante/Desktop/uclass-files/uclass-env/lib/python2.7/site-
packages/django/contrib/gis/geos/libgeos.py", line 119, in <module>
_verinfo = geos_version_info()
File "/Users/armynante/Desktop/uclass-files/uclass-env/lib/python2.7/site
packages/django/contrib/gis/geos/libgeos.py", line 115, in geos_version_info
if not m: raise GEOSException('Could not parse version info string "%s"' % ver)
django.contrib.gis.geos.error.GEOSException: Could not parse version info string
"3.4.2-CAPI-1.8.2 r3921"
이 추적과 관련된 것을 SO 또는 웹에서 찾을 수 없습니다. 정규식 실패일까요? 현재 PSQL 및 GEOS를 다시 설치하여 실행할 수 있는지 확인하려고합니다.
내 요구 사항 파일은 다음과 같습니다.
django==1.4
psycopg2==2.4.4
py-bcrypt==0.4
python-memcached==1.48
south==0.7.3
# Debug Tools
sqlparse==0.1.3
django-debug-toolbar==0.9.1
django-devserver==0.3.1
# Deployment
fabric==1.4
# AWS
# boto==2.1.1
django-storages==1.1.4
django-ses==0.4.1
# ECL
http://packages.elmcitylabs.com/ecl_django-0.5.3.tar.gz#ecl_django
http://packages.elmcitylabs.com/ecl_google-0.2.14.tar.gz#ecl_google
# https://packages.elmcitylabs.com/ecl_tools-0.3.7.tar.gz#ecl_tools
# https://packages.elmcitylabs.com/chargemaster-0.2.19.tar.gz
# https://packages.elmcitylabs.com/ecl_facebook-0.3.12.tar.gz#ecl_facebook
# https://packages.elmcitylabs.com/ecl_twitter-0.3.3.tar.gz#ecl_twitter
# Search
#https://github.com/elmcitylabs/django-haystack/tarball/issue-522#django-haystack
-e git+https://github.com/toastdriven/django-haystack.git#egg=django-haystack
pysolr==2.1.0-beta
# whoosh==2.3.2
# Misc
# PIL
# django-shorturls==1.0.1
# suds==0.4
django-mptt
sorl-thumbnail
stripe
pytz==2013b
이것은 내 해결책입니다 (분명히 내 영어처럼 추악하지만 작동합니다). 문제는 버전 문자열에 RegEx에서 원하지 않는 공백이 있다는 것입니다.
오류 내용 :
GEOSException : 버전 정보 문자열 "3.4.2-CAPI-1.8.2 r3921"을 구문 분석 할 수 없습니다.
그리고 geos_version_info는 다음과 같이 경고합니다.
Regular expression should be able to parse version strings such as '3.0.0rc4-CAPI-1.3.3', '3.0.0-CAPI-1.4.1' or '3.4.0dev-CAPI-1.8.0'
Edit this file: site-packages/django/contrib/gis/geos/libgeos.py
Look for the function: geos_version_info
And change this line:
ver = geos_version().decode()
With this line:
ver = geos_version().decode().split(' ')[0]
In the latest GEOS install, the above answer didn't work... but was close to the problem.
I changed the regex right above the geos_version_info(): from:
version_regex = re.compile(r'^(?P<version>(?P<major>\d+)\.(?P<minor>\d+)\.(?P<subminor>\d+))((rc(?P<release_candidate>\d+))|dev)?-CAPI-(?P<capi_version>\d+\.\d+\.\d+)$')
to be:
version_regex = re.compile(r'^(?P<version>(?P<major>\d+)\.(?P<minor>\d+)\.(?P<subminor>\d+))((rc(?P<release_candidate>\d+))|dev)?-CAPI-(?P<capi_version>\d+\.\d+\.\d+).*$')
Notice the .* added to the end of the regex.
I think this is broken again. A recent upgrade on our FreeBSD server led to this error:
django.contrib.gis.geos.error.GEOSException: Could not parse version info string "3.6.2-CAPI-1.10.2 4d2925d6"
Looks like the regex in Django's libgeos.py
needs to be updated again to account for this different syntax. Nachopro's solution still serves as a workaround.
It appears that this has been fixed in Django as of last March or so. See also Django bug 20036. So upgrading to Django 1.5.4 will solve the problem.
For those folks who don't have 3.6.1 previously installed:
brew unlink geos
- Install 3.6.1 with
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/145b22e8330e094ee148861e72e26c03e73d34a1/Formula/geos.rb
. brew info geos
should show 3.6.1 starred:
This can be fixed by trying the following,
brew switch geos 3.6.1
I fixed the issue by installing PostGIS with Postgres using https://postgresapp.com/downloads.html.
- Install PostGIS (2.2): brew install postgis
- To unlink geos if version is higher than 3.6.1: brew unlink geos
- Install Geos (3.6.1): brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/145b22e8330e094ee148861e72e26c03e73d34a1/Formula/geos.rb
- Switch geos version(latest version is 3.7.2 which is not supported by Django 1.11.3): brew switch geos 3.6.1
- Login to database and create postgis extensions: CREATE EXTENSION postgis; Test postgis extension: SELECT ST_Distance('LINESTRING(-122.33 47.606, 0.0 51.5)'::geography, 'POINT(-21.96 64.15)'::geography);
- Check postgis version: SELECT PostGIS_full_version();
참고URL : https://stackoverflow.com/questions/18643998/geodjango-geosexception-error
'IT Share you' 카테고리의 다른 글
Ruby : 모듈에서 클래스 메소드를 정의 할 수 있습니까? (0) | 2020.12.09 |
---|---|
Ubuntu에 Mercurial을 설치하는 올바른 방법 (0) | 2020.12.09 |
반응 탐색에서 뒤로 버튼 비활성화 (0) | 2020.12.09 |
USB 드라이브에 어떤 개발 도구를 가지고 있습니까? (0) | 2020.12.09 |
GDB로 메모리 범위를 분해하는 방법은 무엇입니까? (0) | 2020.12.09 |