matplotlib / basemap

Plot on map projections (with coastlines and political boundaries) using matplotlib
MIT License
776 stars 392 forks source link

Basemap installation failure in MacOS - Jupyter Notebook #583

Closed mrjan1195 closed 1 year ago

mrjan1195 commented 1 year ago

Hi! I cannot install basemap in MacOS (M2 pro). I am getting the folllowing error with pip install basemap :

DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621 Collecting basemap Using cached basemap-1.3.7.zip (156 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Collecting basemap-data<1.4,>=1.3.2 (from basemap) Using cached basemap_data-1.3.2-py2.py3-none-any.whl (30.5 MB) Collecting pyshp<2.4,>=1.2 (from basemap) Using cached pyshp-2.3.1-py2.py3-none-any.whl (46 kB) Collecting matplotlib<3.8,>=1.5 (from basemap) Obtaining dependency information for matplotlib<3.8,>=1.5 from https://files.pythonhosted.org/packages/1d/57/888776de79e1c2e787368ecbe63e3e57dbec984a5c83220e44c15fefe226/matplotlib-3.7.2-cp39-cp39-macosx_10_12_x86_64.whl.metadata Using cached matplotlib-3.7.2-cp39-cp39-macosx_10_12_x86_64.whl.metadata (5.6 kB) Collecting pyproj<3.6.0,>=1.9.3 (from basemap) Using cached pyproj-3.5.0-cp39-cp39-macosx_10_9_x86_64.whl (8.5 MB) Collecting numpy<1.25,>=1.22 (from basemap) Obtaining dependency information for numpy<1.25,>=1.22 from https://files.pythonhosted.org/packages/9a/cd/d5b0402b801c8a8b56b04c1e85c6165efab298d2f0ab741c2406516ede3a/numpy-1.24.4-cp39-cp39-macosx_10_9_x86_64.whl.metadata Using cached numpy-1.24.4-cp39-cp39-macosx_10_9_x86_64.whl.metadata (5.6 kB) Collecting contourpy>=1.0.1 (from matplotlib<3.8,>=1.5->basemap) Obtaining dependency information for contourpy>=1.0.1 from https://files.pythonhosted.org/packages/44/b4/2bcb2f8afcb7a4652af0fbfa47d5f01ae599c4b35af6f89c1f33c9c56fa3/contourpy-1.1.0-cp39-cp39-macosx_10_9_x86_64.whl.metadata Using cached contourpy-1.1.0-cp39-cp39-macosx_10_9_x86_64.whl.metadata (5.7 kB) Collecting cycler>=0.10 (from matplotlib<3.8,>=1.5->basemap) Using cached cycler-0.11.0-py3-none-any.whl (6.4 kB) Collecting fonttools>=4.22.0 (from matplotlib<3.8,>=1.5->basemap) Obtaining dependency information for fonttools>=4.22.0 from https://files.pythonhosted.org/packages/81/17/a18482c4fa12912913e9f19d9bb6fb1a62f92c377d7043d4bb7b98887da7/fonttools-4.41.1-cp39-cp39-macosx_10_9_x86_64.whl.metadata Using cached fonttools-4.41.1-cp39-cp39-macosx_10_9_x86_64.whl.metadata (150 kB) Collecting kiwisolver>=1.0.1 (from matplotlib<3.8,>=1.5->basemap) Using cached kiwisolver-1.4.4-cp39-cp39-macosx_10_9_x86_64.whl (65 kB) Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.9/site-packages (from matplotlib<3.8,>=1.5->basemap) (23.1) Collecting pillow>=6.2.0 (from matplotlib<3.8,>=1.5->basemap) Obtaining dependency information for pillow>=6.2.0 from https://files.pythonhosted.org/packages/ce/e1/861a5508b9fd82b39c05e4d49c0979a9c8ccab07dae39d0ce72bd5f2299d/Pillow-10.0.0-cp39-cp39-macosx_10_10_x86_64.whl.metadata Using cached Pillow-10.0.0-cp39-cp39-macosx_10_10_x86_64.whl.metadata (9.5 kB) Collecting pyparsing<3.1,>=2.3.1 (from matplotlib<3.8,>=1.5->basemap) Using cached pyparsing-3.0.9-py3-none-any.whl (98 kB) Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.9/site-packages (from matplotlib<3.8,>=1.5->basemap) (2.8.2) Collecting importlib-resources>=3.2.0 (from matplotlib<3.8,>=1.5->basemap) Obtaining dependency information for importlib-resources>=3.2.0 from https://files.pythonhosted.org/packages/29/d1/bed03eca30aa05aaf6e0873de091f9385c48705c4a607c2dfe3edbe543e8/importlib_resources-6.0.0-py3-none-any.whl.metadata Using cached importlib_resources-6.0.0-py3-none-any.whl.metadata (4.2 kB) Requirement already satisfied: certifi in /usr/local/lib/python3.9/site-packages (from pyproj<3.6.0,>=1.9.3->basemap) (2023.7.22) Requirement already satisfied: zipp>=3.1.0 in /usr/local/lib/python3.9/site-packages (from importlib-resources>=3.2.0->matplotlib<3.8,>=1.5->basemap) (3.16.2) Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.9/site-packages (from python-dateutil>=2.7->matplotlib<3.8,>=1.5->basemap) (1.16.0) Using cached matplotlib-3.7.2-cp39-cp39-macosx_10_12_x86_64.whl (7.4 MB) Using cached numpy-1.24.4-cp39-cp39-macosx_10_9_x86_64.whl (19.8 MB) Using cached contourpy-1.1.0-cp39-cp39-macosx_10_9_x86_64.whl (243 kB) Using cached fonttools-4.41.1-cp39-cp39-macosx_10_9_x86_64.whl (2.2 MB) Using cached importlib_resources-6.0.0-py3-none-any.whl (31 kB) Using cached Pillow-10.0.0-cp39-cp39-macosx_10_10_x86_64.whl (3.4 MB) Building wheels for collected packages: basemap Building wheel for basemap (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for basemap (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [116 lines of output]

:58: RuntimeWarning: Cannot find GEOS library and/or headers in standard locations ('/Users/joseangelohokson/local', '/Users/joseangelohokson', '/usr/local', '/usr', '/opt/local', '/opt', '/sw'). Please install the corresponding packages using your software management system or set the environment variable GEOS_DIR to point to the location where GEOS is installed (for example, if 'geos_c.h' is in '/usr/local/include' and 'libgeos_c' is in '/usr/local/lib', then you need to set GEOS_DIR to '/usr/local' /private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/dist.py:945: SetuptoolsDeprecationWarning: The namespace_packages parameter is deprecated. !! ******************************************************************************** Please replace its usage with implicit namespaces (PEP 420). See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages for details. ******************************************************************************** !! ep.load()(self, ep.name, value) running bdist_wheel running build running build_py creating build creating build/lib.macosx-12-x86_64-cpython-39 creating build/lib.macosx-12-x86_64-cpython-39/mpl_toolkits copying src/mpl_toolkits/__init__.py -> build/lib.macosx-12-x86_64-cpython-39/mpl_toolkits creating build/lib.macosx-12-x86_64-cpython-39/mpl_toolkits/basemap copying src/mpl_toolkits/basemap/cm.py -> build/lib.macosx-12-x86_64-cpython-39/mpl_toolkits/basemap copying src/mpl_toolkits/basemap/__init__.py -> build/lib.macosx-12-x86_64-cpython-39/mpl_toolkits/basemap copying src/mpl_toolkits/basemap/test.py -> build/lib.macosx-12-x86_64-cpython-39/mpl_toolkits/basemap copying src/mpl_toolkits/basemap/diagnostic.py -> build/lib.macosx-12-x86_64-cpython-39/mpl_toolkits/basemap copying src/mpl_toolkits/basemap/proj.py -> build/lib.macosx-12-x86_64-cpython-39/mpl_toolkits/basemap copying src/mpl_toolkits/basemap/solar.py -> build/lib.macosx-12-x86_64-cpython-39/mpl_toolkits/basemap running build_ext Error compiling Cython file: ------------------------------------------------------------ ... __geos_major_version__ = GEOS_VERSION_MAJOR #if __geos_version__ != "2.2.3-CAPI-1.1.1": # raise ValueError('version 2.2.3 of the geos library is required') # intialize GEOS (parameters are notice and error function callbacks). initGEOS(notice_h, error_h) ^ ------------------------------------------------------------ src/_geoslib.pyx:136:9: Cannot assign type 'void (char *, char *) except *' to 'GEOSMessageHandler' Error compiling Cython file: ------------------------------------------------------------ ... __geos_major_version__ = GEOS_VERSION_MAJOR #if __geos_version__ != "2.2.3-CAPI-1.1.1": # raise ValueError('version 2.2.3 of the geos library is required') # intialize GEOS (parameters are notice and error function callbacks). initGEOS(notice_h, error_h) ^ ------------------------------------------------------------ src/_geoslib.pyx:136:19: Cannot assign type 'void (char *, char *) except *' to 'GEOSMessageHandler' Compiling src/_geoslib.pyx because it changed. [1/1] Cythonizing src/_geoslib.pyx Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in main() File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel return _build_backend().build_wheel(wheel_directory, config_settings, File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 416, in build_wheel return self._build_with_temp_dir(['bdist_wheel'], '.whl', File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 401, in _build_with_temp_dir self.run_setup() File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 338, in run_setup exec(code, locals()) File "", line 171, in File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 107, in setup return distutils.core.setup(**attrs) File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 185, in setup return run_commands(dist) File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 201, in run_commands dist.run_commands() File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands self.run_command(cmd) File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 1234, in run_command super().run_command(command) File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 346, in run self.run_command("build") File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command self.distribution.run_command(command) File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 1234, in run_command super().run_command(command) File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/build.py", line 131, in run self.run_command(cmd_name) File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command self.distribution.run_command(command) File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 1234, in run_command super().run_command(command) File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 84, in run _build_ext.run(self) File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 345, in run self.build_extensions() File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 467, in build_extensions self._build_extensions_serial() File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 493, in _build_extensions_serial self.build_extension(ext) File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 246, in build_extension _build_ext.build_extension(self, ext) File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/Cython/Distutils/build_ext.py", line 122, in build_extension new_ext = cythonize( File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 1134, in cythonize cythonize_one(*args) File "/private/var/folders/9q/gtxxxnqs13z7yjcptryz4zt40000gn/T/pip-build-env-n30y9c0j/overlay/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one raise CompileError(None, pyx_file) Cython.Compiler.Errors.CompileError: src/_geoslib.pyx [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for basemap Failed to build basemap ERROR: Could not build wheels for basemap, which is required to install pyproject.toml-based projects Note: you may need to restart the kernel to use updated packages.
molinav commented 1 year ago

Hi @mrjan1195! I find two issues to solve in your traceback:

  1. The main error is due to a problem of our _geoslib.pyx file with the latest Cython release 3.0.0. The bug is already fixed (see #581) but the basemap version 1.3.8 is still not released from my side. You have two options:
    • To manually install cython < 3.0.0 in advance and install without build isolation: python -m pip install basemap --no-build-isolation
    • To install not from PyPI but from the hotfix-1.3.8 branch in this repo: python -m pip install git+https://github.com/matplotlib/basemap.git@hotfix-1.3.8#subdirectory=packages/basemap
  2. The former point will not be enough in your case, as your traceback warns that GEOS was not found in the default locations and GEOS_DIR was not defined. Since you are building from the source distribution, you will need to define where your GEOS library is available, so that _geoslib.pyx can be compiled and linked. If your GEOS was installed with Homebrew, probably GEOS_DIR should be something like $(brew --prefix) (not tested, I do not have a MacOS device around).
mrjan1195 commented 1 year ago

Hi @molinav! Thank you for your reply.

For 1, I used "python3 -m pip install cython --no-build-isolation", and I got: Defaulting to user installation because normal site-packages is not writeable Collecting cython Obtaining dependency information for cython from https://files.pythonhosted.org/packages/f6/94/8d553dff3baf9cdd4b2481e59c2cfc8247c0c847170dd10574f81718d142/Cython-3.0.0-py2.py3-none-any.whl.metadata Using cached Cython-3.0.0-py2.py3-none-any.whl.metadata (3.1 kB) Using cached Cython-3.0.0-py2.py3-none-any.whl (1.2 MB) Installing collected packages: cython WARNING: The scripts cygdb, cython and cythonize are installed in '/Users/jahokson/Library/Python/3.9/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed cython-3.0.0

For 2, I have found it using "brew --prefix geos". Then I set it using " export GEOS_DIR="/Users/username/homebrew/opt/geos" ".

I am still getting errors when running "pip3 install basemap" . Defaulting to user instllation because normal site-packages is not writeable Collecting basemap Using cached basemap-1.3.7.zip (156 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Collecting basemap-data<1.4,>=1.3.2 (from basemap) Using cached basemap_data-1.3.2-py2.py3-none-any.whl (30.5 MB) Collecting pyshp<2.4,>=1.2 (from basemap) Using cached pyshp-2.3.1-py2.py3-none-any.whl (46 kB) Collecting matplotlib<3.8,>=1.5 (from basemap) Obtaining dependency information for matplotlib<3.8,>=1.5 from https://files.pythonhosted.org/packages/a3/e5/c9cdc737ea2256285dc1b28e8ecbf649c716cfc7b1ee12a8be6d4cf1feb7/matplotlib-3.7.2-cp39-cp39-macosx_11_0_arm64.whl.metadata Using cached matplotlib-3.7.2-cp39-cp39-macosx_11_0_arm64.whl.metadata (5.6 kB) Collecting pyproj<3.6.0,>=1.9.3 (from basemap) Using cached pyproj-3.5.0-cp39-cp39-macosx_11_0_arm64.whl (5.7 MB) Collecting numpy<1.25,>=1.22 (from basemap) Obtaining dependency information for numpy<1.25,>=1.22 from https://files.pythonhosted.org/packages/14/27/638aaa446f39113a3ed38b37a66243e21b38110d021bfcb940c383e120f2/numpy-1.24.4-cp39-cp39-macosx_11_0_arm64.whl.metadata Using cached numpy-1.24.4-cp39-cp39-macosx_11_0_arm64.whl.metadata (5.6 kB) Collecting contourpy>=1.0.1 (from matplotlib<3.8,>=1.5->basemap) Obtaining dependency information for contourpy>=1.0.1 from https://files.pythonhosted.org/packages/1b/26/192990fa4d10747d59c34d9eac2da0e045ae80aff9ae8a3e8d198146f11f/contourpy-1.1.0-cp39-cp39-macosx_11_0_arm64.whl.metadata Using cached contourpy-1.1.0-cp39-cp39-macosx_11_0_arm64.whl.metadata (5.7 kB) Collecting cycler>=0.10 (from matplotlib<3.8,>=1.5->basemap) Using cached cycler-0.11.0-py3-none-any.whl (6.4 kB) Collecting fonttools>=4.22.0 (from matplotlib<3.8,>=1.5->basemap) Obtaining dependency information for fonttools>=4.22.0 from https://files.pythonhosted.org/packages/de/03/8a5a290c541ffcb6c7e56a1f7acf94d07389c4782d79e290449c9f9c03a5/fonttools-4.41.1-cp39-cp39-macosx_10_9_universal2.whl.metadata Using cached fonttools-4.41.1-cp39-cp39-macosx_10_9_universal2.whl.metadata (150 kB) Collecting kiwisolver>=1.0.1 (from matplotlib<3.8,>=1.5->basemap) Using cached kiwisolver-1.4.4-cp39-cp39-macosx_11_0_arm64.whl (63 kB) Collecting packaging>=20.0 (from matplotlib<3.8,>=1.5->basemap) Using cached packaging-23.1-py3-none-any.whl (48 kB) Collecting pillow>=6.2.0 (from matplotlib<3.8,>=1.5->basemap) Obtaining dependency information for pillow>=6.2.0 from https://files.pythonhosted.org/packages/16/b5/b8e7419e1d746246bca06fd38eb988507b382f3fd2ee5dede2e4154022ad/Pillow-10.0.0-cp39-cp39-macosx_11_0_arm64.whl.metadata Using cached Pillow-10.0.0-cp39-cp39-macosx_11_0_arm64.whl.metadata (9.5 kB) Collecting pyparsing<3.1,>=2.3.1 (from matplotlib<3.8,>=1.5->basemap) Using cached pyparsing-3.0.9-py3-none-any.whl (98 kB) Collecting python-dateutil>=2.7 (from matplotlib<3.8,>=1.5->basemap) Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB) Collecting importlib-resources>=3.2.0 (from matplotlib<3.8,>=1.5->basemap) Obtaining dependency information for importlib-resources>=3.2.0 from https://files.pythonhosted.org/packages/29/d1/bed03eca30aa05aaf6e0873de091f9385c48705c4a607c2dfe3edbe543e8/importlib_resources-6.0.0-py3-none-any.whl.metadata Using cached importlib_resources-6.0.0-py3-none-any.whl.metadata (4.2 kB) Collecting certifi (from pyproj<3.6.0,>=1.9.3->basemap) Obtaining dependency information for certifi from https://files.pythonhosted.org/packages/4c/dd/2234eab22353ffc7d94e8d13177aaa050113286e93e7b40eae01fbf7c3d9/certifi-2023.7.22-py3-none-any.whl.metadata Using cached certifi-2023.7.22-py3-none-any.whl.metadata (2.2 kB) Collecting zipp>=3.1.0 (from importlib-resources>=3.2.0->matplotlib<3.8,>=1.5->basemap) Obtaining dependency information for zipp>=3.1.0 from https://files.pythonhosted.org/packages/8c/08/d3006317aefe25ea79d3b76c9650afabaf6d63d1c8443b236e7405447503/zipp-3.16.2-py3-none-any.whl.metadata Using cached zipp-3.16.2-py3-none-any.whl.metadata (3.7 kB) Requirement already satisfied: six>=1.5 in /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/site-packages (from python-dateutil>=2.7->matplotlib<3.8,>=1.5->basemap) (1.15.0) Using cached matplotlib-3.7.2-cp39-cp39-macosx_11_0_arm64.whl (7.3 MB) Using cached numpy-1.24.4-cp39-cp39-macosx_11_0_arm64.whl (13.9 MB) Using cached contourpy-1.1.0-cp39-cp39-macosx_11_0_arm64.whl (229 kB) Using cached fonttools-4.41.1-cp39-cp39-macosx_10_9_universal2.whl (2.7 MB) Using cached importlib_resources-6.0.0-py3-none-any.whl (31 kB) Using cached Pillow-10.0.0-cp39-cp39-macosx_11_0_arm64.whl (3.1 MB) Using cached certifi-2023.7.22-py3-none-any.whl (158 kB) Using cached zipp-3.16.2-py3-none-any.whl (7.2 kB) Building wheels for collected packages: basemap Building wheel for basemap (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for basemap (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [115 lines of output] /private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/dist.py:945: SetuptoolsDeprecationWarning: The namespace_packages parameter is deprecated. !!

          ********************************************************************************
          Please replace its usage with implicit namespaces (PEP 420).

          See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages for details.
          ********************************************************************************

  !!
    ep.load()(self, ep.name, value)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-universal2-cpython-39
  creating build/lib.macosx-10.9-universal2-cpython-39/mpl_toolkits
  copying src/mpl_toolkits/__init__.py -> build/lib.macosx-10.9-universal2-cpython-39/mpl_toolkits
  creating build/lib.macosx-10.9-universal2-cpython-39/mpl_toolkits/basemap
  copying src/mpl_toolkits/basemap/cm.py -> build/lib.macosx-10.9-universal2-cpython-39/mpl_toolkits/basemap
  copying src/mpl_toolkits/basemap/__init__.py -> build/lib.macosx-10.9-universal2-cpython-39/mpl_toolkits/basemap
  copying src/mpl_toolkits/basemap/test.py -> build/lib.macosx-10.9-universal2-cpython-39/mpl_toolkits/basemap
  copying src/mpl_toolkits/basemap/diagnostic.py -> build/lib.macosx-10.9-universal2-cpython-39/mpl_toolkits/basemap
  copying src/mpl_toolkits/basemap/proj.py -> build/lib.macosx-10.9-universal2-cpython-39/mpl_toolkits/basemap
  copying src/mpl_toolkits/basemap/solar.py -> build/lib.macosx-10.9-universal2-cpython-39/mpl_toolkits/basemap
  running build_ext

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
  __geos_major_version__ = GEOS_VERSION_MAJOR
  #if __geos_version__ != "2.2.3-CAPI-1.1.1":
  #     raise ValueError('version 2.2.3 of the geos library is required')

  # intialize GEOS (parameters are notice and error function callbacks).
  initGEOS(notice_h, error_h)
           ^
  ------------------------------------------------------------

  src/_geoslib.pyx:136:9: Cannot assign type 'void (char *, char *) except *' to 'GEOSMessageHandler'

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
  __geos_major_version__ = GEOS_VERSION_MAJOR
  #if __geos_version__ != "2.2.3-CAPI-1.1.1":
  #     raise ValueError('version 2.2.3 of the geos library is required')

  # intialize GEOS (parameters are notice and error function callbacks).
  initGEOS(notice_h, error_h)
                     ^
  ------------------------------------------------------------

  src/_geoslib.pyx:136:19: Cannot assign type 'void (char *, char *) except *' to 'GEOSMessageHandler'
  Compiling src/_geoslib.pyx because it changed.
  [1/1] Cythonizing src/_geoslib.pyx
  Traceback (most recent call last):
    File "/Users/jahokson/Library/Python/3.9/lib/python/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/Users/jahokson/Library/Python/3.9/lib/python/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/Users/jahokson/Library/Python/3.9/lib/python/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 416, in build_wheel
      return self._build_with_temp_dir(['bdist_wheel'], '.whl',
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 401, in _build_with_temp_dir
      self.run_setup()
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 338, in run_setup
      exec(code, locals())
    File "<string>", line 171, in <module>
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 107, in setup
      return distutils.core.setup(**attrs)
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 185, in setup
      return run_commands(dist)
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
      dist.run_commands()
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
      self.run_command(cmd)
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 1234, in run_command
      super().run_command(command)
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
      cmd_obj.run()
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 346, in run
      self.run_command("build")
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
      self.distribution.run_command(command)
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 1234, in run_command
      super().run_command(command)
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
      cmd_obj.run()
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/build.py", line 131, in run
      self.run_command(cmd_name)
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
      self.distribution.run_command(command)
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 1234, in run_command
      super().run_command(command)
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
      cmd_obj.run()
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 84, in run
      _build_ext.run(self)
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 345, in run
      self.build_extensions()
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 467, in build_extensions
      self._build_extensions_serial()
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 493, in _build_extensions_serial
      self.build_extension(ext)
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 246, in build_extension
      _build_ext.build_extension(self, ext)
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/Cython/Distutils/build_ext.py", line 122, in build_extension
      new_ext = cythonize(
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 1134, in cythonize
      cythonize_one(*args)
    File "/private/var/folders/k2/80sk2b7n4_dcyckzqvy9kmxw0000gn/T/pip-build-env-lnuihrn6/overlay/lib/python3.9/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
      raise CompileError(None, pyx_file)
  Cython.Compiler.Errors.CompileError: src/_geoslib.pyx
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for basemap

molinav commented 1 year ago

Hi @mrjan1195! You still get the compiling issue because it installed Cython 3.0.0, which is our source of the problem. You need to specify the Cython version when installing it:

python3 -m pip install "cython < 3"

After that, you can install the current basemap version (1.3.7) successfully if doing it without build isolation (so that it uses the Cython that you have just installed):

python3 -m pip install --no-build-isolation basemap

Since you now have no warnings about GEOS_DIR, it seems that you solved this issue with the brew call. Let's see if now everything works!

mrjan1195 commented 1 year ago

Hi @molinav! Now, it is working. Thank you so much for your help. Cheers!

molinav commented 1 year ago

Nice to hear! I am closing the issue then. If you have any other problems in the future, feel free to open an issue.