brew install geos

江枫思渺然 提交于 2019-12-05 19:18:09

geo3.8 导致py2中 geodjango不可用

django 报错,不能解析版本

  File "/Users/huoyinghui/gitlab/ange/venv/lib/python2.7/site-packages/django/contrib/gis/geos/__init__.py", line 18, in <module>
    HAS_GEOS = geos_version_info()['version'] >= '3.3.0'
  File "/Users/huoyinghui/gitlab/ange/venv/lib/python2.7/site-packages/django/contrib/gis/geos/libgeos.py", line 191, in geos_version_info
    raise GEOSException('Could not parse version info string "%s"' % ver)
django.contrib.gis.geos.error.GEOSException: Could not parse version info string "3.8.0-CAPI-1.13.1 "

参考

安装geos

➜  ~ brew unlink geos
Unlinking /usr/local/Cellar/geos/3.8.0... 14 symlinks removed
➜  ~ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/145b22e8330e094ee148861e72e26c03e73d34a1/Formula/geos.rb
Updating Homebrew...

^\
==> Consider using `brew extract geos ...`!
This will extract your desired geos version to a stable tap instead of
installing from an unstable URL!

######################################################################## 100.0%
Warning: geos 3.8.0 is available and more recent than version 3.6.1.
==> Downloading https://homebrew.bintray.com/bottles/geos-3.6.1.sierra.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/02/02aa28dcfd38747e924fa486b1607c90ddf5e18c7a400510e3d7f12ef6b90d86?__gda__=exp=1574826709~
######################################################################## 100.0%
Error: SHA256 mismatch
Expected: d061c3cbff08cef91394e3cc3d7e47c6142bc7ca87a6e0209042faf508f30b20
  Actual: 02aa28dcfd38747e924fa486b1607c90ddf5e18c7a400510e3d7f12ef6b90d86
 Archive: /Users/huoyinghui/Library/Caches/Homebrew/downloads/2da1266d3f99f29b31dd9a6a953c2ea4c56b5286a2b4aec0ca3d219c63466830--geos-3.6.1.sierra.bottle.tar.gz
To retry an incomplete download, remove the file above.
Warning: Bottle installation failed: building from source.
==> Installing dependencies for geos: swig
==> Installing geos dependency: swig
==> Downloading https://homebrew.bintray.com/bottles/swig-4.0.1.high_sierra.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/f1/f1df176e92ad7c3a7da641eb67dda3b4e65ed9ec8de76e3b51e366e40cc9662b?__gda__=exp=1574826723~
######################################################################## 100.0%
==> Pouring swig-4.0.1.high_sierra.bottle.tar.gz
🍺  /usr/local/Cellar/swig/4.0.1: 723 files, 5.4MB
==> Downloading http://download.osgeo.org/geos/geos-3.6.1.tar.bz2
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/geos/3.6.1 --enable-python
==> make install
🍺  /usr/local/Cellar/geos/3.6.1: 403 files, 7.2MB, built in 4 minutes 12 seconds
Removing: /Users/huoyinghui/Library/Caches/Homebrew/geos--3.6.1.sierra.bottle.tar.gz... (1.8MB)
Removing: /Users/huoyinghui/Library/Caches/Homebrew/geos--3.6.1.tar.bz2... (1.7MB)
➜  ~

修改代码

libgeos.py

def geos_version_info():
    """
    Returns a dictionary containing the various version metadata parsed from
    the GEOS version string, including the version number, whether the version
    is a release candidate (and what number release candidate), and the C API
    version.
    """
    # ver = geos_version().decode()
    ver = geos_version().decode().split(' ')[0]
    m = version_regex.match(ver)
    if not m:
        raise GEOSException('Could not parse version info string "%s"' % ver)
    return {key: m.group(key) for key in (
        'version', 'release_candidate', 'capi_version', 'major', 'minor', 'subminor')}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!