Cartopy: Cannot install cartopy with pip on windows

Created on 20 Feb 2020  Β·  6Comments  Β·  Source: SciTools/cartopy

Description

I cannot install cartopy with pip, I see several solved issues reporting the same that are reportedly solved, but still it does not work for me. I would like to install it via pip, since then it is easy to set is as a requirement of my own package.

Code to reproduce

pip install cartopy

Traceback

Collecting cartopy
Using cached Cartopy-0.17.0.tar.gz (8.9 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users[user]\AppData\Local\Continuum\anaconda3\envs\dfm_tools_env\python.exe' 'C:\Users[user]\AppData\Local\Continuum\anaconda3\envs\dfm_tools_env\lib\site-packages\pip_vendor\pep517_in_process.py' get_requires_for_build_wheel 'C:\Users[user]\AppData\Local\Temp\tmpvlox3zpd'
cwd: C:\Users[user]\AppData\Local\Temp\pip-install-a7ahxk9g\cartopy
Complete output (5 lines):
setup.py:171: UserWarning: Unable to determine GEOS version. Ensure you have 3.3.3 or later installed, or installation may fail.
'.'.join(str(v) for v in GEOS_MIN_VERSION), ))
setup.py:227: UserWarning: Unable to determine Proj version. Ensure you have 4.9.0 or later installed, or installation may fail.
'.'.join(str(v) for v in PROJ_MIN_VERSION), ))
Proj version 0.0.0 is installed, but cartopy requires at least version 4.9.0.


Operating system

Windows 10

Cartopy version

0.17

pip list

Package Version Location


alabaster 0.7.12
appdirs 1.4.3
arrow 0.15.5
atomicwrites 1.3.0
attrs 19.3.0
Babel 2.8.0
backcall 0.1.0
bleach 3.1.0
bump2version 1.0.0
certifi 2019.11.28
cftime 1.1.0
chardet 3.0.4
Click 7.0
cloudpickle 1.3.0
colorama 0.4.3
coverage 5.0.3
cycler 0.10.0
Cython 0.29.15
DateTime 4.3
decorator 4.4.1
dfm-tools 0.4.3 c:\data\github\dfm_tools
distlib 0.3.0
docutils 0.16
entrypoints 0.3
filelock 3.0.12
flake8 3.7.9
Flask 1.1.1
geos 0.2.2
idna 2.8
imagesize 1.2.0
importlib-metadata 1.5.0
ipykernel 5.1.4
ipython 7.12.0
ipython-genutils 0.2.0
itsdangerous 1.1.0
jedi 0.16.0
Jinja2 2.11.1
jupyter-client 5.3.4
jupyter-core 4.6.2
keyring 21.1.0
kiwisolver 1.1.0
lxml 4.5.0
MarkupSafe 1.1.1
matplotlib 3.1.3
mccabe 0.6.1
more-itertools 8.2.0
netCDF4 1.5.3
numpy 1.18.1
packaging 20.1
pandas 1.0.1
parso 0.6.1
pathtools 0.1.2
pickleshare 0.7.5
Pillow 7.0.0
pip 20.0.2
pkginfo 1.5.0.1
pluggy 0.13.1
proj 0.1.0
prompt-toolkit 3.0.3
py 1.8.1
pycodestyle 2.5.0
pyflakes 2.1.1
Pygments 2.5.2
pyparsing 2.4.6
PyQt5 5.14.1
PyQt5-sip 12.7.1
pytest 5.3.5
pytest-runner 5.2
python-dateutil 2.8.1
pytz 2019.3
pywin32 227
pywin32-ctypes 0.2.0
pyzmq 18.1.1
readme-renderer 24.0
requests 2.22.0
requests-toolbelt 0.9.1
scipy 1.4.1
setuptools 45.2.0.post20200210
Shapely 1.7.0
six 1.14.0
snowballstemmer 2.0.0
Sphinx 2.4.1
sphinxcontrib-applehelp 1.0.1
sphinxcontrib-devhelp 1.0.1
sphinxcontrib-htmlhelp 1.0.2
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-qthelp 1.0.2
sphinxcontrib-serializinghtml 1.1.3
spyder-kernels 0.5.2
toml 0.10.0
tornado 6.0.3
tox 3.14.5
tqdm 4.42.1
traitlets 4.3.3
twine 3.1.1
urllib3 1.25.8
virtualenv 20.0.4
watchdog 0.10.2
wcwidth 0.1.8
webencodings 0.5.1
Werkzeug 1.0.0
wheel 0.34.2
wincertstore 0.2
zipp 3.0.0
zope.interface 4.7.1

Most helpful comment

conda install -c conda-forge cartopy works well and solves the problem in my windows computer.

All 6 comments

You do not have the required dependencies for cartopy installed. Cartopy requires two C++ libraries, geos (https://trac.osgeo.org/geos/) and proj (https://proj.org/), to be available. Unfortunately there happen to be two completely different packages in PyPI that use these same names (https://pypi.org/project/geos/ and https://pypi.org/project/proj/), which is what you have installed. The correct libraries cannot be installed with pip as far as I know.

I'm not a Windows user so I'm not exactly sure which is the best way to get you up and running from this point. Do you have any ideas @QuLogic?

Thanks for your response. The same names indeed confused me, thanks for the clarification. I was aware that the dependencies were not installed, but I am used to pip solving this for me of course. It seems however that pip cannot reach the dependencies, which is inconvenient. Does this mean that I cannot install cartopy via pip at all? Then I will have to a conda install, since this does do the trick. This would however mean that I cannot include cartopy as requirement the setup.py of my own package.

You can also get binaries from Christoph Gohlke: https://www.lfd.uci.edu/~gohlke/pythonlibs/

There cannot be any binaries until we solve #805. Closing as a dupe of #1174.

hi.
i have gotten geos and proj library from OSGeo4W on windows. then, set PATHs of \bin(include dll) and \include (includes such as geos_c.h) . however, follow error happens:

> pip install cartopy

 trace.cpp
  lib/cartopy/trace.cpp(665): fatal error C1083: include フゑむルを開けません。'geos_c.h':No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.26.28801\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for cartopy

how can i solve to set ?

@Cartman0 the solution to that is to specify the include and library directories when calling pip install. Assuming you've used the default OSGeo4W install directory, this would be:
pip install --global-option=build_ext --global-option="-IC:\OSGeo4W\include" --global-option="-LC:\OSGeo4W\lib" cartopy
Pip will then pass these options to MSVC. See this SO post

HTH

conda install -c conda-forge cartopy works well and solves the problem in my windows computer.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MarkWieczorek picture MarkWieczorek  Β·  9Comments

mjarrett picture mjarrett  Β·  5Comments

greglucas picture greglucas  Β·  7Comments

rutgerhofste picture rutgerhofste  Β·  3Comments

leecronce picture leecronce  Β·  8Comments