missing libgeos_c.so on OSX

走远了吗. 提交于 2021-02-06 10:03:52

问题


I am trying to install Postgis in order to use GeoDjango on OSX.

For this, I first uninstalled postgres completely, then I installed everything following the GeoDjango documentation: https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#homebrew

I did the following:

brew update
brew upgrade
brew install postgresql
brew install postgis
brew install gdal
brew install libgeoip

When I run my Django project, I get the following error:

OSError at / dlopen(/usr/local/lib/libgeos_c.so, 6): image not found

I ran

sudo find . -name "libgeos_c*"

And got:

./Library/Frameworks/GEOS.framework/Versions/3/unix/lib/libgeos_c.dylib
./Users/martin/opt/geos-3.3.0/capi/.deps/libgeos_c_la-geos_c.Plo
./Users/martin/opt/geos-3.3.0/capi/.deps/libgeos_c_la-geos_ts_c.Plo
./usr/local/Cellar/geos/3.3.3/lib/libgeos_c.1.dylib
./usr/local/Cellar/geos/3.3.3/lib/libgeos_c.a
./usr/local/Cellar/geos/3.3.3/lib/libgeos_c.dylib
./usr/local/Cellar/geos/3.3.4/lib/libgeos_c.1.dylib
./usr/local/Cellar/geos/3.3.4/lib/libgeos_c.a
./usr/local/Cellar/geos/3.3.4/lib/libgeos_c.dylib
./usr/local/Cellar/geos/3.3.5/lib/libgeos_c.1.dylib
./usr/local/Cellar/geos/3.3.5/lib/libgeos_c.a
./usr/local/Cellar/geos/3.3.5/lib/libgeos_c.dylib
./usr/local/lib/libgeos_c.1.dylib
./usr/local/lib/libgeos_c.a
./usr/local/lib/libgeos_c.dylib

As you can see, no ".so" files at all. Any suggestions?

Edit:

Out of desperation I also installed the KyngChaos Packages and added the following settings:

GEOS_LIBRARY_PATH = '/Library/Frameworks/GEOS.framework/GEOS' 
GDAL_LIBRARY_PATH = '/Library/Frameworks/GDAL.framework/GDAL' 
GEOIP_LIBRARY_PATH = '/usr/local/Cellar/geoip/1.4.8/lib/libGeoIP.dylib'

This solved the problem.


回答1:


Sorry, that KyngChaos solution completely defeats the purpose of using homebrew.

The answer for homebrew users (at least, for this one) is to uninstall geos and its dependencies and then reinstall geos and then its dependencies.

This worked for me:

brew uninstall geos gdal geoip libspatialite librasterlite spatialite-gui spatialite-tools
brew cleanup
brew install geos
brew install gdal geoip libspatialite librasterlite spatialite-gui spatialite-tools
brew cleanup

It seems some geos dependencies are getting out of sync.

You can verify the libraries that need to be installed by tracking what this returns:

python -c 'import _ctypes; _ctypes.dlopen("/usr/local/lib/libgdal.dylib")'

You'll see something like

Reason: Incompatible library version: [some geos dependent library].dylib requires version X.X.X or later, but libgeos_c.1.8.0.dylib provides version X.X.X.

brew uninstall [some geos dependency]
brew install [some geos dependency]
brew cleanup

Then rerun the above python command and either the problem will be resolved or it'll reveal another dependency to uninstall/install.




回答2:


I solved it this way.

$ brew install postgresql
$ brew install postgis
$ brew install gdal
$ brew install libgeoip

then in Django settings set this:

GEOS_LIBRARY_PATH = '/usr/local/Cellar/geos/3.4.2/lib/libgeos_c.1.dylib'

Then it worked for me.




回答3:


The installation instructions appears to hold the answer, which is to set the environment variable $GEOS_LIBRARY_PATH.




回答4:


Same here - after installing everything as directed, I went back and added the KyngChaos libraries, then added the three export statements to my ~/.bash_profile as listed above. This fixed my issue.




回答5:


I had this same issue and was able to solve it by uninstalling GDAL from Homebrew and installing the GDAL Complete package from KyngChaos: http://www.kyngchaos.com/software/frameworks



来源:https://stackoverflow.com/questions/11294556/missing-libgeos-c-so-on-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!