PythonAnywhere 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?