skip to Main Content

I try to install cartopy for work but I got an error and I don’t know how to solve it.

"C:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.33.31629binHostX86x64cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -I. -I./lib/cartopy -IC:UsersSogataAppDataLocalTemppip-build-env-nkjqwiqmoverlayLibsite-packagesnumpycoreinclude -IC:UsersSogataAppDataLocalProgramsPythonPython310include -IC:UsersSogataAppDataLocalProgramsPythonPython310Include "-IC:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.33.31629include" "-IC:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.33.31629ATLMFCinclude" "-IC:Program FilesMicrosoft Visual Studio2022CommunityVCAuxiliaryVSinclude" "-IC:Program Files (x86)Windows Kits10include10.0.19041.0ucrt" "-IC:Program Files (x86)Windows Kits10\include10.0.19041.0\um" "-IC:Program Files (x86)Windows Kits10\include10.0.19041.0\shared" "-IC:Program Files (x86)Windows Kits10\include10.0.19041.0\winrt" "-IC:Program Files (x86)Windows Kits10\include10.0.19041.0\cppwinrt" "-IC:Program Files (x86)Windows KitsNETFXSDK4.8includeum" /EHsc /Tplib/cartopy/trace.cpp /Fobuildtemp.win-amd64-cpython-310Releaselib/cartopy/trace.obj
      trace.cpp
      lib/cartopy/trace.cpp(767): fatal error C1083: Impossible d'ouvrir le fichier includeÿ: 'geos_c.h'ÿ: No such file or directory
      error: command 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX86\x64\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cartopy
Failed to build cartopy
ERROR: Could not build wheels for cartopy, which is required to install pyproject.toml-based projects

I think I need a library but I don’t know which one

2

Answers


  1. From the cartopy docs:

    The easiest way to install Cartopy is by using Conda. If conda is already installed, installation is as easy as:

    conda install -c conda-forge cartopy
    

    I highly recommend you follow their advice. cartopy relies on GDAL, which is a collection of non-python compiled libaries which are really tough to manage with pip. Conda does this for you, and well.

    The cartopy docs link to miniconda, which is great. Don’t install anaconda – it pollutes your base env with a bunch of packages from the defaults channel, which is incompatible with conda-forge. Best in my opinion would be to install one of the "conda-forge-first" installers:

    • miniforge – a version of miniconda which prioritizes the conda-forge channel
    • mambaforge – (my recommendation) installs mamba with a conda-forge preference. mamba is a compiled, parallel, super fast version of conda. Downside is it crashes harder with worse debug messages, so if you ever run into trouble using mamba, you can try the same command using conda and see what’s going wrong.
    Login or Signup to reply.
  2. I am definitely worthy to answer this question. I have stuck in this question for 2 months, in which I spent 5 whole days to solve it but still in fiasco.

    VS code is my often-used tool to program. Other packages can be simply installed via following command in powerhell or terminal.

    pip install package
    

    However, it could’t work out for the cartopy. I followed the error message to install Visual Studio Build Tool 2022 yet appearing following traceback.

    > ERROR: Could not build wheels for cartopy, which is required to install pyproject.toml-based projects
    

    I tried almost 20 ways suggested by website articles and none of them could resolve my question. Until one time, a article tells that cartopy is hard to install via ‘pip’. And other guys always recommend that the easiest way to install the Cartopy is by using conda. Then I installed miniconda (not the anaconda). I could successfully installed the cartopy package via conda or pip in miniconda powershell. While scared thing happened again when I tried to import it.

    No module is named cartopy.

    Afterwards, I thought it may the conda is not in environmental path. Sadly, Same error still occured. These are two articles that nearly but not solved my matter, which could help others possibly:
    ModuleNotFoundError: No module named ‘cartopy’ &
    How to activate conda environment in VS code.

    Then I asked other 4 friends who use python but using spyder and jupyter of anaconda to code. Their advice is like the articles that sounds good but don’t work out in my case.

    Later, a japanese article describes that 1. you cannot use pip from python and conda at the same time; 2. If a certain package is installed by cartopy, it is improper to be install by pip again; 3. Basemap-cartopy is not being supported anymore, so it is not advisable to use cartopy. Then I realized that all the endeavors I made is vain.

    My current idea is to replace cartopy by using other drawing libraries, such folium, plotly. You can find more visualization packages here.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search