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

Unable to install cartopy from pip on MacOSX #1270

Closed
cmaclell opened this issue Jan 23, 2019 · 11 comments
Closed

Unable to install cartopy from pip on MacOSX #1270

cmaclell opened this issue Jan 23, 2019 · 11 comments

Comments

@cmaclell
Copy link

cmaclell commented Jan 23, 2019

Description

I am unable to install cartopy 0.17.0 from pypi, but have no problem installing directly from the git using pip install git+https://github.com/SciTools/cartopy@master. Seems like some kind of issue with the version on pypi.

Code to reproduce

$ pip install cartopy

on MacOS X

Traceback

$ pip install cartopy
Collecting cartopy
  Using cached https://files.pythonhosted.org/packages/e5/92/fe8838fa8158931906dfc4f16c5c1436b3dd2daf83592645b179581403ad/Cartopy-0.17.0.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  Complete output from command /Users/chris/.pyenv/versions/3.7.1/envs/clue/bin/python3.7 /Users/chris/.pyenv/versions/3.7.1/envs/clue/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/1t/mrcp_h8913378fwmsc5k01k80000gn/T/tmpcbaxbjw_:
  Traceback (most recent call last):
    File "/Users/chris/.pyenv/versions/3.7.1/envs/clue/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
      main()
    File "/Users/chris/.pyenv/versions/3.7.1/envs/clue/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/Users/chris/.pyenv/versions/3.7.1/envs/clue/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 54, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/private/var/folders/1t/mrcp_h8913378fwmsc5k01k80000gn/T/pip-build-env-4zgg2er_/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 115, in get_requires_for_build_wheel
      return _get_build_requires(config_settings, requirements=['wheel'])
    File "/private/var/folders/1t/mrcp_h8913378fwmsc5k01k80000gn/T/pip-build-env-4zgg2er_/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 101, in _get_build_requires
      _run_setup()
    File "/private/var/folders/1t/mrcp_h8913378fwmsc5k01k80000gn/T/pip-build-env-4zgg2er_/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 85, in _run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 36, in <module>
      import versioneer
  ModuleNotFoundError: No module named 'versioneer'

  ----------------------------------------
Command "/Users/chris/.pyenv/versions/3.7.1/envs/clue/bin/python3.7 /Users/chris/.pyenv/versions/3.7.1/envs/clue/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/1t/mrcp_h8913378fwmsc5k01k80000gn/T/tmpcbaxbjw_" failed with error code 1 in /private/var/folders/1t/mrcp_h8913378fwmsc5k01k80000gn/T/pip-install-89uiyomd/cartopy

I also tried installing versioneer first and get the same error as above:

$ pip install versioneer
Requirement already satisfied: versioneer in /Users/chris/.pyenv/versions/3.7.1/envs/clue/lib/python3.7/site-packages (0.18)

$ pip install cartopy
Collecting cartopy
  Using cached https://files.pythonhosted.org/packages/e5/92/fe8838fa8158931906dfc4f16c5c1436b3dd2daf83592645b179581403ad/Cartopy-0.17.0.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  Complete output from command /Users/chris/.pyenv/versions/3.7.1/envs/clue/bin/python3.7 /Users/chris/.pyenv/versions/3.7.1/envs/clue/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/1t/mrcp_h8913378fwmsc5k01k80000gn/T/tmpcbaxbjw_:
  Traceback (most recent call last):
    File "/Users/chris/.pyenv/versions/3.7.1/envs/clue/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
      main()
    File "/Users/chris/.pyenv/versions/3.7.1/envs/clue/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/Users/chris/.pyenv/versions/3.7.1/envs/clue/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 54, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/private/var/folders/1t/mrcp_h8913378fwmsc5k01k80000gn/T/pip-build-env-4zgg2er_/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 115, in get_requires_for_build_wheel
      return _get_build_requires(config_settings, requirements=['wheel'])
    File "/private/var/folders/1t/mrcp_h8913378fwmsc5k01k80000gn/T/pip-build-env-4zgg2er_/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 101, in _get_build_requires
      _run_setup()
    File "/private/var/folders/1t/mrcp_h8913378fwmsc5k01k80000gn/T/pip-build-env-4zgg2er_/overlay/lib/python3.7/site-packages/setuptools/build_meta.py", line 85, in _run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 36, in <module>
      import versioneer
  ModuleNotFoundError: No module named 'versioneer'

  ----------------------------------------
Command "/Users/chris/.pyenv/versions/3.7.1/envs/clue/bin/python3.7 /Users/chris/.pyenv/versions/3.7.1/envs/clue/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/1t/mrcp_h8913378fwmsc5k01k80000gn/T/tmpcbaxbjw_" failed with error code 1 in /private/var/folders/1t/mrcp_h8913378fwmsc5k01k80000gn/T/pip-install-89uiyomd/cartopy
OSX with Python 3.7.1

Operating system

Mac OSX Mojave, Python 3.7.1

Cartopy version

0.17.0

conda list

Not using conda.

pip list

appdirs==1.4.3
atomicwrites==1.2.1
attrs==18.2.0
cftime==1.0.3.4
cgen==2017.1
Click==7.0
Cython==0.29.3
decorator==4.3.0
Flask==1.0.2
Flask-Cors==3.0.7
imageio==2.4.1
itsdangerous==1.1.0
Jinja2==2.10
MarkupSafe==1.1.0
more-itertools==5.0.0
netCDF4==1.4.2
numpy==1.16.0
pandas==0.23.4
Pillow==5.4.1
pluggy==0.8.1
progressbar==2.5
py==1.7.0
pymbolic==2018.1
pyshp==2.0.1
pytest==4.1.1
python-dateutil==2.7.5
pytools==2019.1
pytz==2018.9
PyYAML==3.13
scipy==1.2.0
Shapely==1.6.4.post2
six==1.12.0
versioneer==0.18
Werkzeug==0.14.1
xarray==0.11.2
@cmaclell
Copy link
Author

Also, if I do pip install Cartopy==0.16.0 then everything installs properly, so seems like an issue with 0.17.0.

@ajdawson
Copy link
Member

I think that the versioneer.py file from the project root may be missing from our source distribution, does that sound right @pelson @QuLogic?

@QuLogic
Copy link
Member

QuLogic commented Jan 23, 2019

It's already included:

$ wget https://files.pythonhosted.org/packages/e5/92/fe8838fa8158931906dfc4f16c5c1436b3dd2daf83592645b179581403ad/Cartopy-0.17.0.tar.gz
--2019-01-23 17:46:05--  https://files.pythonhosted.org/packages/e5/92/fe8838fa8158931906dfc4f16c5c1436b3dd2daf83592645b179581403ad/Cartopy-0.17.0.tar.gz
Resolving files.pythonhosted.org (files.pythonhosted.org)... 151.101.1.63, 151.101.65.63, 151.101.129.63, ...
Connecting to files.pythonhosted.org (files.pythonhosted.org)|151.101.1.63|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8887169 (8.5M) [binary/octet-stream]
Saving to: ‘Cartopy-0.17.0.tar.gz’

Cartopy-0.17.0.tar.gz                 100%[=======================================================================>]   8.47M  2.24MB/s    in 3.8s

2019-01-23 17:46:09 (2.23 MB/s) - ‘Cartopy-0.17.0.tar.gz’ saved [8887169/8887169]

$ tar tf Cartopy-0.17.0.tar.gz | grep versioneer
Cartopy-0.17.0/versioneer.py

I also created a venv and installed without issue, so I'm confused:

$ python3 -m venv /tmp/what
$ source /tmp/what/bin/activate
$ pip install cartopy
Collecting cartopy
  Downloading https://files.pythonhosted.org/packages/e5/92/fe8838fa8158931906dfc4f16c5c1436b3dd2daf83592645b179581403ad/Cartopy-0.17.0.tar.gz (8.9MB)
    100% |████████████████████████████████| 8.9MB 1.9MB/s 
  Installing build dependencies ... done
Collecting numpy>=1.10 (from cartopy)
  Using cached https://files.pythonhosted.org/packages/3d/10/62224c551acfd3a3583ad16d1e0f1c9e9c333e74479dc51977c31836119c/numpy-1.16.0-cp37-cp37m-manylinux1_x86_64.whl
Collecting shapely>=1.5.6 (from cartopy)
  Downloading https://files.pythonhosted.org/packages/97/36/1af447160f713d72f35dd7e749788367b7a13285c4af2fbd675128aa4e99/Shapely-1.6.4.post2-cp37-cp37m-manylinux1_x86_64.whl (1.5MB)
    100% |████████████████████████████████| 1.5MB 2.6MB/s 
Collecting pyshp>=1.1.4 (from cartopy)
  Downloading https://files.pythonhosted.org/packages/08/3e/3bda7dfdbee0d7a22d38443f5cc8d154ff6d4701e615f4c07bf1ed003563/pyshp-2.0.1.tar.gz (214kB)
    100% |████████████████████████████████| 215kB 6.5MB/s 
Collecting six>=1.3.0 (from cartopy)
  Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=0.7.2 in /tmp/what/lib/python3.7/site-packages (from cartopy) (40.4.3)
Installing collected packages: numpy, shapely, pyshp, six, cartopy
  Running setup.py install for pyshp ... done
  Running setup.py install for cartopy ... done
Successfully installed cartopy-0.17.0 numpy-1.16.0 pyshp-2.0.1 shapely-1.6.4.post2 six-1.12.0

@oceandatalab
Copy link

Had the same issue, in fact the problem comes from pip version 19.x and the pyproject.toml file in the cartopy tarball.

When the TOML file is available, pip 19.x activates PEP517 (https://www.python.org/dev/peps/pep-0517/) and its implementation currently has an issue: it does not include the current working directory in the Python path during the installation, so all the packages whose setup.py import their own/embedded modules are broken. This explains why pip cannot find the versioneer.py file during the cartopy installation.

Since the TOML file has been removed from the cartopy repository in a recent commit, installing from github does not trigger PEP517 and everything works fine.

There is an ongoing discussion on the pip repository about this: pypa/pip#6163 (cartopy is also mentioned there btw, see pypa/pip#6163 (comment))

The current workaround is to call pip install --no-use-pep517 cartopy, but uploading a new tarball which does not contain the TOML file (or with a modified setup.py that includes the current working directory before importing versioneer) would definitely be more user-friendly.

@pelson
Copy link
Member

pelson commented Feb 1, 2019

Thanks for the information @oceandatalab.
As you say, we've removed pyproject.toml for the next release, and it is good to have a workaround while pip & PEP517 is fully fleshed out.

I don't think there is anything more to be done in the cartopy codebase, but happy to re-open if there is.

Cheers,

@johnbarrett
Copy link

I am having the same issue. I am trying to install on macOS

@yuanyuanzhou23
Copy link

Hi @johnbarrett, did you try pip install git+https://github.com/SciTools/cartopy@master. This worked after I installed Cython. HTH

@devleaks
Copy link

Hi,
pip install git+https://github.com/SciTools/cartopy@master
failed on this:
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/miniconda3/include -arch x86_64 -I/usr/local/miniconda3/include -arch x86_64 -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1 -I/usr/local/miniconda3/include -I./lib/cartopy -I/usr/local/miniconda3/lib/python3.7/site-packages/numpy/core/include -I/usr/local/Cellar/geos/3.8.1/include -I/usr/local/miniconda3/include/python3.7m -c lib/cartopy/trace.cpp -o build/temp.macosx-10.7-x86_64-3.7/lib/cartopy/trace.o warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found] lib/cartopy/trace.cpp:615:10: fatal error: 'ios' file not found #include "ios" ^~~~~ 1 warning and 1 error generated. error: command 'gcc' failed with exit status 1 ---------------------------------------- Rolling back uninstall of Cartopy

This is on macos 10.14.6, conda 4.8.3.

@greglucas
Copy link
Contributor

I was running into that same thing fairly frequently. I put this in my~/.bash_profile which I think may help you. (Check out those linked issues if not)

# Adding additional flags for building C++ stuff
# https://github.com/matplotlib/matplotlib/issues/13609
# https://github.com/huggingface/neuralcoref/issues/97#issuecomment-436638466
export CFLAGS=-stdlib=libc++
# MACOSX_DEPLOYMENT for Python
MACOSX_DEPLOYMENT_TARGET=10.14

@dopplershift
Copy link
Contributor

You should be able to get away with just MACOSX_DEPLOYMENT_TARGET=10.14--that should help make sure you pull in the right CFLAGS/compiler chain.

@maxzzze
Copy link

maxzzze commented Apr 27, 2020

Someone should re-open this issue

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

No branches or pull requests