Forums

Unable to pip install Cartopy

Hello,

I'm trying to install the Cartopy package for use with matplotlib in my virtual env, however there seems to be a problem with the Proj4 version... I'm not sure how to fix this.

Collecting Cartopy==0.14.0 (from -r requirements.txt (line 2))
Using cached Cartopy-0.14.0.tar.gz
Complete output from command python setup.py egg_info:
Unable to find pgen, not compiling formal grammar.
warning: no files found matching '*.pyx' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.pxd' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.h' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.pxd' under directory 'Cython/Utility'

Installed /tmp/pip-build-cfi_la_6/Cartopy/.eggs/Cython-0.25.2-py3.5-linux-x86_64.egg
/tmp/pip-build-cfi_la_6/Cartopy/setup.py:230: UserWarning: Unable to determine Proj4 version. Ensure you have 4.9.0 or later installed, or installation may fail.
  '.'.join(str(v) for v in PROJ_MIN_VERSION), ))
Proj4 version 0.0.0 is installed, but cartopy requires at least version 4.9.0.

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-cfi_la_6/Cartopy/

Any help is appreciated.

Cam

What was the exact 'pip install' command that you used?

inside my virtual environment I ran

$ pip install cartopy

Collecting cartopy
Downloading Cartopy-0.14.2.tar.gz (8.4MB)
100% |████████████████████████████████| 8.4MB 158kB/s

It then sits there for many minutes before bombing out with the error above...

Complete output from command python setup.py egg_info:
Unable to find pgen, not compiling formal grammar.
warning: no files found matching '*.pyx' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.pxd' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.h' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.pxd' under directory 'Cython/Utility'

Installed /tmp/pip-build-9l6wj5cv/cartopy/.eggs/Cython-0.25.2-py3.5-linux-x86_64.egg
/tmp/pip-build-9l6wj5cv/cartopy/setup.py:230: UserWarning: Unable to determine Proj4 version. Ensure you have 4.9.0 or later installed, or installation may fail.
  '.'.join(str(v) for v in PROJ_MIN_VERSION), ))
Proj4 version 0.0.0 is installed, but cartopy requires at least version 4.9.0.

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-9l6wj5cv/cartopy/

I have also tried running this command in a regular console, but get a similar error relating to Proj4 as below:

$ pip install --user cartopy
Collecting cartopy
Using cached Cartopy-0.14.2.tar.gz
Complete output from command python setup.py egg_info:
Proj4 4.9.0 must be installed.

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-KEE27J/cartopy/

Could it be that both errors are stating that Proj4 is not installed? If this is correct, how would I go about installing Proj4? Although I thought I installed another package that required Proj4 and that didn't complain...

Thanks,

I think there's a version mismatch between the version of Proj4 that we have installed and the one the Cartopy is looking for. Perhaps an older version of Cartopy will work.

It seems like the Proj4 isn't reporting its version number correctly? Is there a way to update this?

I can see that libproj-dev version 4.8.0-2ubuntu2 is installed, this should work with the Cartopy 0.13 versions, but when I try and pip install I get a similar error about Proj4 version 0.0.0 being installed...

$ pip install cartopy==0.13.1
Collecting cartopy==0.13.1
Using cached Cartopy-0.13.1.tar.gz
Complete output from command python setup.py egg_info:
/tmp/pip-build-33s8e5uk/cartopy/setup.py:224: UserWarning: Unable to determine Proj4 version. Ensure you have 4.8.0 or later installed, or installation may fail.
  '.'.join(str(v) for v in PROJ_MIN_VERSION), ))
Proj4 version 0.0.0 is installed, but cartopy requires at least version 4.8.0.

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-33s8e5uk/cartopy/
(venv35) 09:46 ~ $ pip install cartopy==0.13.0
Collecting cartopy==0.13.0
Using cached Cartopy-0.13.0.tar.gz
Complete output from command python setup.py egg_info:
/tmp/pip-build-h6x2ynse/cartopy/setup.py:221: UserWarning: Unable to determine Proj4 version. Ensure you have 4.8.0 or later installed, or installation may fail.
  '.'.join(str(v) for v in PROJ_MIN_VERSION), ))
Proj4 version 0.0.0 is installed, but cartopy requires at least version 4.8.0.

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-h6x2ynse/cartopy/
(venv35) 09:46 ~ $ pip install cartopy==0.12.0.5                                                                                                                                                                 
Collecting cartopy==0.12.0.5
Downloading Cartopy-0.12.0.5.tar.gz (7.7MB)
100% |████████████████████████████████| 7.7MB 157kB/s 
Complete output from command python setup.py egg_info:
/tmp/pip-build-2tpd79fx/cartopy/setup.py:221: UserWarning: Unable to determine Proj4 version. Ensure you have 4.8.0 or later installed, or installation may fail.
  '.'.join(str(v) for v in PROJ_MIN_VERSION), ))
Proj4 version 0.0.0 is installed, but cartopy requires at least version 4.8.0.

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-2tpd79fx/cartopy/
(venv35) 09:47 ~ $ pip install cartopy==0.12.0.4
Collecting cartopy==0.12.0.4
Downloading Cartopy-0.12.0.4.tar.gz (7.7MB)
100% |████████████████████████████████| 7.7MB 162kB/s 
Complete output from command python setup.py egg_info:
/tmp/pip-build-k6ppf0k3/cartopy/setup.py:221: UserWarning: Unable to determine Proj4 version. Ensure you have 4.8.0 or later installed, or installation may fail.
  '.'.join(str(v) for v in PROJ_MIN_VERSION), ))
Proj4 version 0.0.0 is installed, but cartopy requires at least version 4.8.0.

Am I able to build and compile a local copy of Proj4 and add it to my path?

Thanks

I think I found the root cause of this error... I had another pip package installed called proj - a project management package, and this was being found during the setup.py. So, I've cleared that out and now pip is reporting that Proj4 is not installed...

$ pip install cartopy==0.13.1
Collecting cartopy==0.13.1
Using cached Cartopy-0.13.1.tar.gz
Complete output from command python setup.py egg_info:
Proj4 4.8.0 must be installed.

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-rky87pcf/cartopy/

As mentioned earlier libproj-dev_4.8.0-2ubuntu2 (and libproj0_4.8.0-2ubuntu2 and proj-data_4.8.0-2ubuntu2) are installed, but maybe proj-bin_4.8.0-2ubuntu2 the command line tools also need to be installed?

maybe! You can try downloading or compiling them yourself?

It's been a while, but thought I'd give an update in case anyone else finds this interesting... Was able to compile the 4.9.3 source code from Proj.4 as the recent versions of Cartopy require greater than 4.9. Just needed to pass my local folder to configure

./configure --prefix=/your_local_folder/Proj.4

I ran into trouble again when trying to

pip install Cartopy==0.15.1

as it could not locate geodesic.h despite being on the $LD_LIBRARY_PATH environment variable. The chestnut was to point pip in its direction...

pip install --global-option=build_ext --global-option="-I/your_local_folder/Proj.4/include" Cartopy==0.15.1

This worked a treat and all is well with the world again...

Great! Thanks for sharing the details, hopefully that will help anyone else trying to install the same package.

Ok, since i am a numbnut and had to pay to get out of the tarpit because i used up all my seconds in the attempts i will summarize this post:

  1. Download Proj.4 from their website - see rohshamboyha's post
  2. Unzip it somewhere using "tar xvzf archivename.tar.gz"
  3. Enter the unzipped folder and type ./configure ... -> see roshamboyha's post and and type make, then make install
  4. Update your Library references:

        export LD_LIBRARY_PATH=/pathto/proj-4.9.1/lib/$LIBRARY_PATH
        export PATH=/pathto/proj-4.9.1/bin:$PATH
    
  5. type roshamboyas command pip3.6 install --user ... keep the -I in

[edit by admin: formatting]

Thanks for posting that!

Thanks! I'm receiving the following errors when I execute "make install":

20:37 ~/proj-4.9.3 $ make install Making install in src make[1]: Entering directory /home/KenPryor67/proj-4.9.3/src' make[2]: Entering directory/home/KenPryor67/proj-4.9.3/src' /bin/mkdir -p '/usr/local/lib' /bin/bash ../libtool --mode=install /usr/bin/install -c libproj.la '/usr/local/lib' libtool: install: /usr/bin/install -c .libs/libproj.so.12.0.0 /usr/local/lib/libproj.so.12.0.0 /usr/bin/install: cannot create regular file '/usr/local/lib/libproj.so.12.0.0': Permission denied make[2]: *** [install-libLTLIBRARIES] Error 1 make[2]: Leaving directory /home/KenPryor67/proj-4.9.3/src' make[1]: *** [install-am] Error 2 make[1]: Leaving directory/home/KenPryor67/proj-4.9.3/src' make: *** [install-recursive] Error 1

I am following the directions on the Proj website (https://proj.org/install.html). Any further guidance would be greatly appreciated. Thanks!

Update: I was able to compile and install Proj v4.9.3 within a virtual environment (home/KenPryor67/.virtualenvs/cartopy_2_7), however when I execute the command "pip install --global-option=build_ext --global-option="-I/home/KenPryor67/proj-4.9.3/include" Cartopy==0.15.1", I still receive the error that "Proj4 4.9.0 must be installed". What further actions are necessary to successfully install Cartopy? Could this be a path issue? Thanks again for all your help!

Update #2: After executing the commands: export LD_LIBRARY_PATH=/home/KenPryor67/proj-4.9.3/lib/$LIBRARY_PATH export PATH=/home/KenPryor67/proj-4.9.3/bin:$PATH I was able to successfully install Cartopy v0.15.1. Cartopy now runs as expected and generated this beautiful radar image of Hurricane Laura.enter image description here