Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install works ok, failure importing (Cartopy 0.13, Python 3) #726

Closed
ispmarin opened this issue Feb 11, 2016 · 7 comments
Closed

Install works ok, failure importing (Cartopy 0.13, Python 3) #726

ispmarin opened this issue Feb 11, 2016 · 7 comments

Comments

@ispmarin
Copy link

cartopy installs correctly using pip, but when importing I get the following stack trace:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-701c7294a873> in <module>()
      4 import matplotlib
      5 import matplotlib.pyplot as plt
----> 6 import cartopy

/home/user/.virtualenvs/maps/lib/python3.4/site-packages/cartopy/__init__.py in <module>()
    109 # convenience.
    110 import cartopy.crs
--> 111 import cartopy.feature

/home/user/.virtualenvs/maps/lib/python3.4/site-packages/cartopy/feature.py in <module>()
     30 import six
     31 
---> 32 from cartopy.io.ogc_clients import WFSGeometrySource
     33 import cartopy.io.shapereader as shapereader
     34 import cartopy.crs

/home/user/.virtualenvs/maps/lib/python3.4/site-packages/cartopy/io/ogc_clients.py in <module>()
     55     _OWSLIB_AVAILABLE = False
     56 
---> 57 import cartopy.crs as ccrs
     58 from cartopy.io import LocatedImage, RasterSource
     59 from cartopy.img_transform import warp_array

AttributeError: 'module' object has no attribute 'crs'

On a Ubuntu 14.04 install, with libproj-dev version 4.8.0-2ubuntu2 and libgdal version 1.10.1+dfsg-5ubuntu1.

@ispmarin
Copy link
Author

Now a different error if I try to import cartopy directly:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-701c7294a873> in <module>()
      4 import matplotlib
      5 import matplotlib.pyplot as plt
----> 6 import cartopy

/home/user/.virtualenvs/maps/lib/python3.4/site-packages/cartopy/__init__.py in <module>()
    109 # convenience.
    110 import cartopy.crs
--> 111 import cartopy.feature

/home/user/.virtualenvs/maps/lib/python3.4/site-packages/cartopy/feature.py in <module>()
     30 import six
     31 
---> 32 from cartopy.io.ogc_clients import WFSGeometrySource
     33 import cartopy.io.shapereader as shapereader
     34 import cartopy.crs

/home/user/.virtualenvs/maps/lib/python3.4/site-packages/cartopy/io/ogc_clients.py in <module>()
     57 import cartopy.crs as ccrs
     58 from cartopy.io import LocatedImage, RasterSource
---> 59 from cartopy.img_transform import warp_array
     60 
     61 

/home/user/.virtualenvs/maps/lib/python3.4/site-packages/cartopy/img_transform.py in <module>()
     24 
     25 import numpy as np
---> 26 import scipy.spatial
     27 
     28 import cartopy.crs as ccrs

ImportError: No module named 'scipy'

@QuLogic
Copy link
Member

QuLogic commented Feb 11, 2016

Since you want to do some plotting, you should use the plotting extra mode for installation: pip install cartopy[plotting], which should get you the other dependencies.

However, SciPy is a pain to build, so it would be best if you install it from your package manager sudo apt-get install python3-scipy.

@ispmarin
Copy link
Author

Well, this is not very clear from the docs when installing cartopy.
I suggest that the logic should be inverted: doing a pip install cartopy should install all that is needed to do a import cartopy without failures. If that needs plotting or other things they should be dependencies.

Actually, Scipy is quite easy to install with pip, only requiring BLAS/LAPACK, FFT and a Fortran compiler. As I want to use virtualenvs and keep each env independent I tend to not install system packages except python itself.

@QuLogic
Copy link
Member

QuLogic commented Feb 12, 2016

Yes, sorry, I forgot to mention that that is a known bug. The default install should not depend on any of the plotting-related libraries and will be fixed in 0.14.

@ispmarin
Copy link
Author

Thanks!

@efiring
Copy link

efiring commented Sep 24, 2016

@QuLogic, was this fixed in 0.14 as you predicted? If so, this can be closed, correct?

@btengels
Copy link

btengels commented Oct 15, 2016

Same problem. I've installed from source and from conda and get the same result. My error is slightly different but it still installs w/out any error and then fails on import. Is 0.14 a dev version?

In [1]: import cartopy
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-8327782196fd> in <module>()
----> 1 import cartopy

/Users/btengels/anaconda3/lib/python3.5/site-packages/cartopy/__init__.py in <module>()
    108 # Commonly used sub-modules. Imported here to provide end-user
    109 # convenience.
--> 110 import cartopy.crs
    111 import cartopy.feature

/Users/btengels/anaconda3/lib/python3.5/site-packages/cartopy/crs.py in <module>()
     35 import six
     36 
---> 37 from cartopy._crs import CRS, Geocentric, Geodetic, Globe, PROJ4_RELEASE
     38 import cartopy.trace
     39 

ImportError: dlopen(/Users/btengels/anaconda3/lib/python3.5/site-packages/cartopy/_crs.cpython-35m-darwin.so, 2): Library not loaded: @rpath/./libproj.9.dylib
  Referenced from: /Users/btengels/anaconda3/lib/python3.5/site-packages/cartopy/_crs.cpython- 35m-darwin.so
  Reason: image not found

Update:
Nearly the same error after deleting/reinstalling proj4 libproj files (version 4.9) and doing the same with cartopy (version 0.14 from source). Everything is identical up to the ImportError:

ImportError: dlopen(/Users/btengels/anaconda3/lib/python3.5/site-packages/Cartopy-0.14.0-py3.5-macosx-10.5-x86_64.egg/cartopy/_crs.cpython-35m-darwin.so, 2): Library not loaded: @rpath/libproj.12.dylib
  Referenced from: /Users/btengels/anaconda3/lib/python3.5/site-packages/Cartopy-0.14.0-py3.5-macosx-10.5-x86_64.egg/cartopy/_crs.cpython-35m-darwin.so
  Reason: image not found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants