conda-forge / shapely-feedstock

A conda-smithy repository for shapely.
BSD 3-Clause "New" or "Revised" License
9 stars 20 forks source link

OSError: Could not find lib c or load any of its variants []. #53

Closed jakeeegarcia-alb closed 5 years ago

jakeeegarcia-alb commented 5 years ago

Issue: I canot seem to import Line or any other when using from shapely.geometry import Line


Environment (conda list):

``` $ conda list # Name Version Build Channel attrs 19.1.0 py_0 conda-forge boost-cpp 1.70.0 hd59e818_1 conda-forge bzip2 1.0.8 h01d97ff_0 conda-forge ca-certificates 2019.6.16 hecc5488_0 conda-forge cairo 1.16.0 h0ab9d94_1001 conda-forge certifi 2019.6.16 py37_1 conda-forge click 7.0 py_0 conda-forge click-plugins 1.1.1 py_0 conda-forge cligj 0.5.0 py_0 conda-forge curl 7.65.2 ha441bb4_0 expat 2.2.6 h0a44026_0 fiona 1.8.4 py37h9a122fd_0 fontconfig 2.13.1 h1027ab8_1000 conda-forge freetype 2.10.0 h24853df_0 conda-forge freexl 1.0.5 h1de35cc_1002 conda-forge gdal 2.3.3 py37hbe65578_0 geopandas 0.5.1 py_0 conda-forge geos 3.7.1 h0a44026_1000 conda-forge gettext 0.19.8.1 h46ab8bc_1002 conda-forge giflib 5.1.7 h01d97ff_1 conda-forge glib 2.58.3 h9d45998_1002 conda-forge hdf4 4.2.13 hf3c6af0_1002 conda-forge hdf5 1.10.4 nompi_h0cbb7df_1106 conda-forge icu 58.2 h0a44026_1000 conda-forge jpeg 9c h1de35cc_1001 conda-forge json-c 0.13.1 h1de35cc_1001 conda-forge kealib 1.4.10 hecf890f_1003 conda-forge krb5 1.16.1 hddcf347_7 libblas 3.8.0 11_openblas conda-forge libcblas 3.8.0 11_openblas conda-forge libcurl 7.65.2 h051b688_0 libcxx 4.0.1 hcfea43d_1 libcxxabi 4.0.1 hcfea43d_1 libdap4 3.19.1 h3d3e54a_0 libedit 3.1.20181209 hb402a30_0 libffi 3.2.1 h475c297_4 libgdal 2.3.3 h0950a36_0 libgfortran 3.0.1 0 conda-forge libiconv 1.15 h01d97ff_1005 conda-forge libkml 1.3.0 hed7d534_1010 conda-forge liblapack 3.8.0 11_openblas conda-forge libnetcdf 4.6.2 h6b88ef6_1001 conda-forge libopenblas 0.3.6 hd44dcd8_6 conda-forge libpng 1.6.37 h2573ce8_0 conda-forge libpq 11.2 h051b688_0 libspatialindex 1.9.0 h6de7cb9_1 conda-forge libspatialite 4.3.0a h0cd9627_1026 conda-forge libssh2 1.8.2 hcdc9a53_2 conda-forge libtiff 4.0.10 hd08fb8f_1003 conda-forge libxml2 2.9.9 hd80cff7_2 conda-forge lz4-c 1.8.3 h6de7cb9_1001 conda-forge munch 2.3.2 py_0 conda-forge ncurses 6.1 h0a44026_1 numpy 1.17.0 py37h6b0580a_0 conda-forge openjpeg 2.3.1 hc1feee7_0 conda-forge openssl 1.1.1c h01d97ff_0 conda-forge pandas 0.25.0 py37h86efe34_0 conda-forge pcre 8.43 h0a44026_0 pip 19.1.1 py37_0 pixman 0.38.0 h01d97ff_1003 conda-forge poppler 0.79.0 hd5eb092_0 conda-forge poppler-data 0.4.9 1 conda-forge proj4 5.2.0 h6de7cb9_1004 conda-forge pyproj 1.9.6 py37h9c430a6_0 python 3.7.3 h359304d_0 python-dateutil 2.8.0 py_0 conda-forge pytz 2019.2 py_0 conda-forge readline 7.0 h1de35cc_5 rtree 0.8.3 py37h666c49c_1002 conda-forge setuptools 41.0.1 py37_0 shapely 1.6.4 py37h79c6f3e_1005 conda-forge six 1.12.0 py37_1000 conda-forge sqlite 3.29.0 ha441bb4_0 tk 8.6.8 ha441bb4_0 wheel 0.33.4 py37_0 xerces-c 3.2.2 h4db8090_1003 conda-forge xz 5.2.4 h1de35cc_4 zlib 1.2.11 h1de35cc_3 zstd 1.4.0 ha9f0a20_0 conda-forge ```


Details about conda and system ( conda info ):

``` $ conda info active environment : GIS active env location : /Users/jacob/anaconda3/envs/GIS shell level : 2 user config file : /Users/jacob/.condarc populated config files : /Users/jacob/.condarc conda version : 4.7.10 conda-build version : 3.18.8 python version : 3.7.3.final.0 virtual packages : base environment : /Users/jacob/anaconda3 (writable) channel URLs : https://conda.anaconda.org/conda-forge/ https://repo.anaconda.com/pkgs/main/osx-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/osx-64 https://repo.anaconda.com/pkgs/r/noarch package cache : /Users/jacob/anaconda3/pkgs /Users/jacob/.conda/pkgs envs directories : /Users/jacob/anaconda3/envs /Users/jacob/.conda/envs platform : osx-64 user-agent : conda/4.7.10 requests/2.22.0 CPython/3.7.3 Darwin/18.7.0 OSX/10.14.6 UID:GID : 501:20 netrc file : None offline mode : False ``` ``` $conda info - s sys.version: 3.7.3 (default, Mar 27 2019, 16:54:48) ... sys.prefix: /Users/jacob/anaconda3 sys.executable: /Users/jacob/anaconda3/bin/python conda location: /Users/jacob/anaconda3/lib/python3.7/site-packages/conda conda-build: /Users/jacob/anaconda3/bin/conda-build conda-convert: /Users/jacob/anaconda3/bin/conda-convert conda-debug: /Users/jacob/anaconda3/bin/conda-debug conda-develop: /Users/jacob/anaconda3/bin/conda-develop conda-env: /Users/jacob/anaconda3/bin/conda-env conda-index: /Users/jacob/anaconda3/bin/conda-index conda-inspect: /Users/jacob/anaconda3/bin/conda-inspect conda-metapackage: /Users/jacob/anaconda3/bin/conda-metapackage conda-render: /Users/jacob/anaconda3/bin/conda-render conda-server: /Users/jacob/anaconda3/bin/conda-server conda-skeleton: /Users/jacob/anaconda3/bin/conda-skeleton conda-verify: /Users/jacob/anaconda3/bin/conda-verify user site dirs: CIO_TEST: CONDA_DEFAULT_ENV: GIS CONDA_EXE: /Users/jacob/anaconda3/bin/conda CONDA_PREFIX: /Users/jacob/anaconda3/envs/GIS CONDA_PREFIX_1: /Users/jacob/anaconda3 CONDA_PROMPT_MODIFIER: (GIS) CONDA_PYTHON_EXE: /Users/jacob/anaconda3/bin/python CONDA_ROOT: /Users/jacob/anaconda3 CONDA_SHLVL: 2 PATH: /Users/jacob/anaconda3/bin:/Users/jacob/anaconda3/envs/GIS/bin:/Users/jacob/anaconda3/condabin:/usr/local/git/bin:/sw/bin:/usr/local/bin:/usr/local:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/Cellar/netcdf/4.6.3_1/bin:/usr/local/Cellar/mpich3/include:/usr/local/opt/python/libexec/bin:/Users/jacob/Desktop/WRF4/ncl/ncl_6/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/opt/inetutils/libexec/gnubin:/usr/local/bin:/usr/local/sbin:/Users/jacob/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin REQUESTS_CA_BUNDLE: SSL_CERT_FILE: ```

these are the steps I took before executing the aforementioned command to import Line

  1. Went into the anaconda Navigator
  2. Created an environment
  3. Installed geopandas through conda install -c conda-forge geopandas
  4. Opened my environment with python and with pycharm
  5. Executed the command from shapely.geometry import Line

I then get the following error code from

Python

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jacob/anaconda3/envs/GIS/lib/python3.7/site-packages/shapely/geometry/__init__.py", line 4, in <module>
    from .base import CAP_STYLE, JOIN_STYLE
  File "/Users/jacob/anaconda3/envs/GIS/lib/python3.7/site-packages/shapely/geometry/base.py", line 17, in <module>
    from shapely.coords import CoordinateSequence
  File "/Users/jacob/anaconda3/envs/GIS/lib/python3.7/site-packages/shapely/coords.py", line 8, in <module>
    from shapely.geos import lgeos
  File "/Users/jacob/anaconda3/envs/GIS/lib/python3.7/site-packages/shapely/geos.py", line 113, in <module>
    free = load_dll('c').free
  File "/Users/jacob/anaconda3/envs/GIS/lib/python3.7/site-packages/shapely/geos.py", line 56, in load_dll
    libname, fallbacks or []))
OSError: Could not find lib c or load any of its variants [].

From pyCharm (I used the environment I created)

from shapely.geometry import Line
Traceback (most recent call last):
  File "<input>", line 1, in <module>
ImportError: cannot import name 'Line' from 'shapely.geometry' (/Users/jacob/anaconda3/envs/GIS/lib/python3.7/site-packages/shapely/geometry/__init__.py)

Hoping someone could help. Thanks!

ocefpaf commented 5 years ago

I don't know about PyCharm and how it works with conda but you are mixing packages from defaults and conda-forge. Please see https://conda-forge.org/docs/user/tipsandtricks.html#how-to-fix-it

jakeeegarcia-alb commented 5 years ago

Hi,

I have done what was mentioned in the help document; however, I still get the same error.

This is my environment now (conda list):

(GIS) bash-3.2$ conda list
# packages in environment at /Users/jacob/anaconda3/envs/GIS:
#
# Name                    Version                   Build  Channel
attrs                     19.1.0                     py_0    conda-forge
boost-cpp                 1.70.0               h75728bb_2    conda-forge
bzip2                     1.0.8                h01d97ff_0    conda-forge
ca-certificates           2019.6.16            hecc5488_0    conda-forge
cairo                     1.16.0            he1c11cd_1002    conda-forge
certifi                   2019.6.16                py37_1    conda-forge
cfitsio                   3.470                h389770f_1    conda-forge
click                     7.0                        py_0    conda-forge
click-plugins             1.1.1                      py_0    conda-forge
cligj                     0.5.0                      py_0    conda-forge
curl                      7.65.3               h22ea746_0    conda-forge
expat                     2.2.5             h6de7cb9_1003    conda-forge
fiona                     1.8.6            py37h39889d8_4    conda-forge
fontconfig                2.13.1            h6b1039f_1001    conda-forge
freetype                  2.10.0               h24853df_1    conda-forge
freexl                    1.0.5             h1de35cc_1002    conda-forge
gdal                      2.4.2            py37h39889d8_4    conda-forge
geopandas                 0.5.1                      py_0    conda-forge
geos                      3.7.2                h6de7cb9_1    conda-forge
geotiff                   1.5.1                h83de174_2    conda-forge
gettext                   0.19.8.1          h46ab8bc_1002    conda-forge
giflib                    5.1.7                h01d97ff_1    conda-forge
glib                      2.58.3            h9d45998_1002    conda-forge
hdf4                      4.2.13            hf3c6af0_1002    conda-forge
hdf5                      1.10.5          nompi_h0cbb7df_1100    conda-forge
icu                       64.2                 h6de7cb9_0    conda-forge
jpeg                      9c                h1de35cc_1001    conda-forge
json-c                    0.13.1            h1de35cc_1001    conda-forge
kealib                    1.4.10            h6659575_1005    conda-forge
krb5                      1.16.3            hcfa6398_1001    conda-forge
libblas                   3.8.0               11_openblas    conda-forge
libcblas                  3.8.0               11_openblas    conda-forge
libcurl                   7.65.3               h16faf7d_0    conda-forge
libcxx                    8.0.0                         4    conda-forge
libcxxabi                 8.0.0                         4    conda-forge
libdap4                   3.20.2            hae55d67_1000    conda-forge
libedit                   3.1.20170329      hcfe32e1_1001    conda-forge
libffi                    3.2.1             h6de7cb9_1006    conda-forge
libgdal                   2.4.2                hf77bb78_4    conda-forge
libgfortran               3.0.1                         0    conda-forge
libiconv                  1.15              h01d97ff_1005    conda-forge
libkml                    1.3.0             hed7d534_1010    conda-forge
liblapack                 3.8.0               11_openblas    conda-forge
libnetcdf                 4.6.2             h1a02027_1002    conda-forge
libopenblas               0.3.6                hd44dcd8_6    conda-forge
libpng                    1.6.37               h2573ce8_0    conda-forge
libpq                     11.5                 h756f0eb_0    conda-forge
libspatialindex           1.9.0                h6de7cb9_1    conda-forge
libspatialite             4.3.0a            he369b6e_1029    conda-forge
libssh2                   1.8.2                hcdc9a53_2    conda-forge
libtiff                   4.0.10            hd08fb8f_1003    conda-forge
libxml2                   2.9.9                h12c6b28_2    conda-forge
lz4-c                     1.8.3             h6de7cb9_1001    conda-forge
munch                     2.3.2                      py_0    conda-forge
ncurses                   6.1               h0a44026_1002    conda-forge
numpy                     1.17.0           py37h6b0580a_0    conda-forge
openjpeg                  2.3.1                hc1feee7_0    conda-forge
openssl                   1.1.1c               h01d97ff_0    conda-forge
pandas                    0.25.0           py37h86efe34_0    conda-forge
pcre                      8.41              h0a44026_1003    conda-forge
pip                       19.2.1                   py37_0    conda-forge
pixman                    0.38.0            h01d97ff_1003    conda-forge
poppler                   0.67.0               hd5eb092_7    conda-forge
poppler-data              0.4.9                         1    conda-forge
postgresql                11.5                 h25afefd_0    conda-forge
proj4                     6.1.0                h2cc77ee_2    conda-forge
pyproj                    2.2.1            py37h804dea5_0    conda-forge
python                    3.7.3                h93065d6_1    conda-forge
python-dateutil           2.8.0                      py_0    conda-forge
pytz                      2019.2                     py_0    conda-forge
readline                  8.0                  hcfe32e1_0    conda-forge
rtree                     0.8.3           py37h666c49c_1002    conda-forge
setuptools                41.0.1                   py37_0    conda-forge
shapely                   1.6.4           py37h0567c5e_1006    conda-forge
six                       1.12.0                py37_1000    conda-forge
sqlite                    3.29.0               hb7d70f7_0    conda-forge
tk                        8.6.9             h2573ce8_1002    conda-forge
tzcode                    2019a             h01d97ff_1002    conda-forge
wheel                     0.33.4                   py37_0    conda-forge
xerces-c                  3.2.2             hbda6038_1004    conda-forge
xz                        5.2.4             h1de35cc_1001    conda-forge
zlib                      1.2.11            h01d97ff_1005    conda-forge
zstd                      1.4.0                ha9f0a20_0    conda-forge

Details about my system (conda info):

(GIS) bash-3.2$ conda info

     active environment : GIS
    active env location : /Users/jacob/anaconda3/envs/GIS
            shell level : 2
       user config file : /Users/jacob/.condarc
 populated config files : /Users/jacob/.condarc
          conda version : 4.7.10
    conda-build version : 3.18.8
         python version : 3.7.3.final.0
       virtual packages : 
       base environment : /Users/jacob/anaconda3  (writable)
           channel URLs : https://conda.anaconda.org/conda-forge/osx-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/osx-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/osx-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /Users/jacob/anaconda3/pkgs
                          /Users/jacob/.conda/pkgs
       envs directories : /Users/jacob/anaconda3/envs
                          /Users/jacob/.conda/envs
               platform : osx-64
             user-agent : conda/4.7.10 requests/2.22.0 CPython/3.7.3 Darwin/18.7.0 OSX/10.14.6
                UID:GID : 501:20
             netrc file : None
           offline mode : False

conda info -s gives:

(GIS) bash-3.2$ conda info -s
sys.version: 3.7.3 (default, Mar 27 2019, 16:54:48) 
...
sys.prefix: /Users/jacob/anaconda3
sys.executable: /Users/jacob/anaconda3/bin/python
conda location: /Users/jacob/anaconda3/lib/python3.7/site-packages/conda
conda-build: /Users/jacob/anaconda3/bin/conda-build
conda-convert: /Users/jacob/anaconda3/bin/conda-convert
conda-debug: /Users/jacob/anaconda3/bin/conda-debug
conda-develop: /Users/jacob/anaconda3/bin/conda-develop
conda-env: /Users/jacob/anaconda3/bin/conda-env
conda-index: /Users/jacob/anaconda3/bin/conda-index
conda-inspect: /Users/jacob/anaconda3/bin/conda-inspect
conda-metapackage: /Users/jacob/anaconda3/bin/conda-metapackage
conda-render: /Users/jacob/anaconda3/bin/conda-render
conda-server: /Users/jacob/anaconda3/bin/conda-server
conda-skeleton: /Users/jacob/anaconda3/bin/conda-skeleton
conda-verify: /Users/jacob/anaconda3/bin/conda-verify
user site dirs: 

CIO_TEST: <not set>
CONDA_DEFAULT_ENV: GIS
CONDA_EXE: /Users/jacob/anaconda3/bin/conda
CONDA_PREFIX: /Users/jacob/anaconda3/envs/GIS
CONDA_PREFIX_1: /Users/jacob/anaconda3
CONDA_PROMPT_MODIFIER: (GIS) 
CONDA_PYTHON_EXE: /Users/jacob/anaconda3/bin/python
CONDA_ROOT: /Users/jacob/anaconda3
CONDA_SHLVL: 2
PATH: /Users/jacob/anaconda3/bin:/Users/jacob/anaconda3/envs/GIS/bin:/Users/jacob/anaconda3/condabin:/usr/local/git/bin:/sw/bin:/usr/local/bin:/usr/local:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/Cellar/netcdf/4.6.3_1/bin:/usr/local/Cellar/mpich3/include:/usr/local/opt/python/libexec/bin:/Users/jacob/Desktop/WRF4/ncl/ncl_6/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/opt/inetutils/libexec/gnubin:/usr/local/bin:/usr/local/sbin:/Users/jacob/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
REQUESTS_CA_BUNDLE: <not set>
SSL_CERT_FILE: <not set>

and cat .condarc:

(GIS) bash-3.2$ cat .condarc
ssl_verify: true
channels:
  - conda-forge
  - defaults
channel_priority: strict

the error from the python prompt is still the same:

from shapely.geometry import Line

Last login: Sat Aug 10 23:00:22 on ttys000
-bash: HOME: command not found
/Users/jacob/.anaconda/navigator/a.tool ; exit;
(base) Jacobs-MacBook-Pro:~ jacob$ /Users/jacob/.anaconda/navigator/a.tool ; exit;
Python 3.7.3 | packaged by conda-forge | (default, Jul  1 2019, 14:38:56) 
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from shapely.geometry import Line
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jacob/anaconda3/envs/GIS/lib/python3.7/site-packages/shapely/geometry/__init__.py", line 4, in <module>
    from .base import CAP_STYLE, JOIN_STYLE
  File "/Users/jacob/anaconda3/envs/GIS/lib/python3.7/site-packages/shapely/geometry/base.py", line 17, in <module>
    from shapely.coords import CoordinateSequence
  File "/Users/jacob/anaconda3/envs/GIS/lib/python3.7/site-packages/shapely/coords.py", line 8, in <module>
    from shapely.geos import lgeos
  File "/Users/jacob/anaconda3/envs/GIS/lib/python3.7/site-packages/shapely/geos.py", line 113, in <module>
    free = load_dll('c').free
  File "/Users/jacob/anaconda3/envs/GIS/lib/python3.7/site-packages/shapely/geos.py", line 56, in load_dll
    libname, fallbacks or []))
OSError: Could not find lib c or load any of its variants [].

It still pointing to site-packages, but I created a new environment and set conda-forge to priority and set this conda config --set channel_priority strict. I am not sure why this is happening

ocefpaf commented 5 years ago

You may have a system geos that could be interfering. It should not be a problem though but I don't have a macOS to debug that.

ocefpaf commented 5 years ago

Check if you installed geos with macports or homebrew.

jakeeegarcia-alb commented 5 years ago

Hi. None, I haven't installed geos via homebrew either. I checked with brew list and brew cask list.

ocefpaf commented 5 years ago

I cannot reproduce that error. I recommend you to start from a clean miniconda installation and to see if you can fix that.

Guochaoer commented 3 years ago

I met the same error after I updated my Mac OS to Big Sur. Then I tried to track back the line that raised the error. And I found that it is the Line 113 of the following file:

File "/Users/jacob/anaconda3/envs/GIS/lib/python3.7/site-packages/shapely/geos.py", line 113, in free = load_dll('c').free

I tried to replace this line with: "free = load_dll('c', fallbacks=alt_paths).free"

Then it works !!!

I don't even know what the keyword "fallbacks" represents, but it works anyway. Hope anyone can explain this!

Thenio commented 3 years ago

@Guochaoer your solution works. Amazing 🥇 After up Mac OS to Big Sur, I made miniconda installation from scratch but the error was the same.

`~/opt/miniconda3/lib/python3.8/site-packages/shapely/geos.py in 111 _lgeos = load_dll('geos_c', fallbacks=alt_paths) 112 --> 113 free = load_dll('c').free 114 free.argtypes = [c_void_p] 115 free.restype = None

~/opt/miniconda3/lib/python3.8/site-packages/shapely/geos.py in load_dll(libname, fallbacks, mode) 52 else: 53 # No shared library was loaded. Raise OSError. ---> 54 raise OSError( 55 "Could not find lib {0} or load any of its variants {1}.".format( 56 libname, fallbacks or []))

OSError: Could not find lib c or load any of its variants [].`

goranrauker commented 3 years ago

I met the same error after I updated my Mac OS to Big Sur.

I had to replace the following line File "/Users/jacob/anaconda3/envs/GIS/lib/python3.7/site-packages/shapely/geos.py", line 113, in free = load_dll('c').free

I tried to replace this line with:

free = load_dll('c', fallbacks=["/usr/lib/libSystem.dylib"]).free

And this works!

lucashusted commented 3 years ago

+1 for the solution listed here that this issue started after updating to Big Sur and attempted to run

import geopandas

The solution is to replace line 113 in the ~/shapely/geos.py file with

free = load_dll('c', fallbacks=["/usr/lib/libSystem.dylib"]).free

This should definitely be added as a fix for the next release.

LucianaNieto commented 2 years ago

I met the same error after I updated my Mac OS to Big Sur.

I had to replace the following line File "/Users/jacob/anaconda3/envs/GIS/lib/python3.7/site-packages/shapely/geos.py", line 113, in free = load_dll('c').free

I tried to replace this line with:

free = load_dll('c', fallbacks=["/usr/lib/libSystem.dylib"]).free

And this works!

THANK YOU!!! Mac OS Monterey version 12.2.1