2

I tried doing "conda install -c conda-forge cartopy in an anaconda prompt, but that does not do anything even though it says done.

In my command prompt, I try pip install cartopy and the message I will put below keeps popping up. I have downloaded one of the cartopy extension packages on uci.edu as well, but that does not seem to work. Also, I have wheel package installed and as far as I have seen all of the dependencies as well, but I could be wrong. Any suggestions would help, thank you.

Error message:

Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [5 lines of output]
      setup.py:117: UserWarning: Unable to determine GEOS version. Ensure you have 3.7.2 or later installed, or installation may fail.
        warnings.warn(
      setup.py:166: UserWarning: Unable to determine Proj version. Ensure you have 8.0.0 or later installed, or installation may fail.
        warnings.warn(
      Proj version 0.0.0 is installed, but cartopy requires at least version 8.0.0.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
kramer101
  • 21
  • 1
  • 2
  • 1
    To build `cartopy`, you need to have recent versions of the `GEOS` and `Proj` libraries installed. – MattDMo Apr 21 '22 at 20:48
  • I did pip install --upgrade GEOS and pip install --upgrade Proj as well, and both gave a few "requirement already satisfied". Not sure what else to do. – kramer101 Apr 21 '22 at 21:04
  • These aren't `pip` packages, they're compiled C libraries and headers that need to be on your system so you can compile `cartopy`. What operating system are you using? – MattDMo Apr 21 '22 at 22:08
  • Check out [Christoph Gohlke's Python Extension Packages for Windows repository](https://www.lfd.uci.edu/~gohlke/pythonlibs/), specifically the [`cartopy`](https://www.lfd.uci.edu/~gohlke/pythonlibs/#cartopy) section. He has a **ton** of pre-compiled wheels for all sorts of scientific Python modules. They're unofficial, but incredibly useful. – MattDMo Apr 21 '22 at 22:29
  • Make sure you're getting the correct wheel for your version and distribution of Python. – MattDMo Apr 21 '22 at 22:31
  • Yeah I downloaded one of the cartopy tools from that page but I just have to figure out what to do with it. Thanks for the help. I'll have to check the wheel version too. – kramer101 Apr 21 '22 at 22:31
  • I'm having the same issue but I am running my code on a Mac. I don't understand why pip install Proj isn't working since that is described as a dependency. – user2813606 May 16 '22 at 20:15

3 Answers3

1

You can resolve this error by downloading the binary for the cartopy library from the link given below

https://www.lfd.uci.edu/~gohlke/pythonlibs/#cartopy

Follow the below steps

(1) Download the appropriate binary for your python version.

(2) After that, open the file explorer and go to downloads.

(3) Do Shift + Right click on mouse and select the option "open a powershell window here".

(4) Once the powershell window is open type the following "pip install " and then do either of the following

(a) Type out the entire name of the wheel file you downloaded.

(b) Type the first 3-4 letters, click Tab and use the up and down arrow button to navigate to correct wheel file you wish to use.

(5) Once the statement "pip install [wheel file name here]" is done, press enter.

(6) If the downloaded wheel file is not correct for your version of python, download the next wheel file from the link given above.

Follow the above steps till you successfully install the Cartopy library.

0

Like others have said, you need proj installed before installing cartopy.

If you create a conda environment.yml file like this...

name: my_env
channels:
  - conda-forge
dependencies:
  - python>=3.10
  - cartopy
  - proj # Required to build cartopy (can't be installed with pip)

then you can create that conda environment with this...

conda env create -f environment.yml
blaylockbk
  • 2,503
  • 2
  • 28
  • 43
0

Another solution from cartopy's documentation that worked for me (WSL Ubuntu):

from https://scitools.org.uk/cartopy/docs/latest/installing.html

sudo apt-y install libgeos-dev

then,

pip install cartopy