Closed YuujinHwang closed 2 years ago
Hi @YuujinHwang!
You are right. Because we do not have pre-built wheels for MacOS, your computer tries with the source distribution (the zip file) but I made a mistake and some files are missing in the zip file uploaded to PyPI (see #532). This is fixed but I haven't released basemap
1.3.2 yet.
Can you try to install basemap
using the following sdist (this is the current development status):
basemap-1.3.1+dev.zip
If it works for you, then I will release basemap
1.3.2 today and in the future you can install it with pip
as you were trying to do.
Also I see that you are trying to link basemap
with GEOS 3.10.2. There are known problems with some drawing using newer GEOS (see #522), so I would recommend you to link basemap
with GEOS < 3.9, which is known to work well.
I have just released basemap
1.3.2 that includes the fix for the issue with the source distribution that you were facing. Could you try to repeat the installation with the same command as before? Now it should work:
python -m pip install basemap
@YuujinHwang May I ask you if your problem got solved by installing basemap
1.3.2 as indicated in my previous message?
@molinav Is issue #522 also fixed by this new release?
@AgilentGCMS Your issue is still not solved in basemap
1.3.2, but I keep it in my backlog to study it when I get some time. The workaround for the moment is still to pin GEOS < 3.9.
I am closing this issue due to lack of feedback. Since this was a problem with the broken sdist
in PyPI and this is solved in basemap
1.3.2, this issue should be solved with this release. If that is not the case, feel free to reopen the issue.
Hi! I am working on Macbook pro with basemap, but I met some issues. When I try to pip install basemap, there is something wrong with this. But I have already brew install geos, what's wrong? Thanks!
@YuujinHwang @molinav
@YuujinHwang The fix that I made to solve the broken source distribution package was not enough to make basemap
installable on MacOS. I needed to make another patch as shown in #539 to ensure that the GEOS shared library (dylib) can be found. May I ask you to check if the fix also works for your case? You would need to do the following:
export GEOS_DIR="/opt/homebrew/Cellar/geos/3.10.2"
git clone https://github.com/matplotlib/basemap.git
cd basemap/packages/basemap
git checkout bugfix-539
python -m pip install .
@molinav Hey! This got me past the install step (M1 Pro), with an extra
python3 -c "import utils; utils.GeosLibrary('3.5.1').build(installdir='${GEOS_DIR}')"
step in the middle. All working now 🚀
Python 3.10.2, pip 22.0.4
@odrusso Thanks for the feedback! You have to use your additional command in case that you also need to build GEOS from source. I didn't include it in my previous comment because the original issue was trying to link the GEOS library available from Homebrew. Good to see that with GEOS from source it also works flawlessly on MacOS.
I will tag a new basemap
patch version (1.3.3) very soon. Then it will be possible to install basemap
on MacOS using the source distributions from PyPI; basemap
1.3.3 should therefore work on:
GEOS_DIR
environment variable, and CMake if also building GEOS from source).GEOS_DIR
environment variable, and GEOS from their package managers).@odrusso Thanks for the feedback! You have to use your additional command in case that you also need to build GEOS from source. I didn't include it in my previous comment because the original issue was trying to link the GEOS library available from Homebrew. Good to see that with GEOS from source it also works flawlessly on MacOS.
I will tag a new basemap
patch version (1.3.3) very soon. Then it will be possible to install basemap
on MacOS using the source distributions from PyPI; basemap
1.3.3 should therefore work on:
GEOS_DIR
environment variable, and CMake if also building GEOS from source).GEOS_DIR
environment variable, and GEOS from their package managers).I have just released
basemap
1.3.2 that includes the fix for the issue with the source distribution that you were facing. Could you try to repeat the installation with the same command as before? Now it should work:python -m pip install basemap
hi @molinav , I'm facing the same problem as the issue creator does. My OS is macOS 12.4. and the version 1.3.2 and 1.3.3 can not install as well, the reported final error is below,
File "/private/var/folders/95/d5hdsfz15nv_ljrcg3l51pt00000gn/T/pip-install-9hm5xce1/numpy_4b6eeeaaaff94e648df3ce8efda8c580/numpy/distutils/fcompiler/gnu.py", line 144, in get_flags_linker_so
os.environ['MACOSX_DEPLOYMENT_TARGET'] = target
File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py", line 684, in __setitem__
value = self.encodevalue(value)
File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py", line 756, in encode
raise TypeError("str expected, not %s" % type(value).__name__)
TypeError: str expected, not int
Hi @junchih! It looks like you might having the following issue with numpy
: https://github.com/numpy/numpy/issues/18093
Are you trying to build numpy
from source? It could also be that your system already had numpy
installed but with a version prior to the patch from the link above.
Thx @molinav, I see the reason.
Theoretically anybody with macOS builtin python 3.8, or brew install python@3
(python 3.9) will be punched by this error. Because of https://github.com/matplotlib/basemap/blob/v1.3.2/packages/basemap/pyproject.toml#L5-L6.
Only macOS with python 3.10 could work. But https://github.com/Homebrew/homebrew-core/issues/91421. Let's wait!
The basemap
series 1.3.x is aiming to put basemap
in shape for proper distribution under as many operating systems and Python versions as possible.
Unfortunately I do not have expertise with MacOS and this might have introduced some regressions. The lines that you mention are very useful for an eventual fix for Python 3.8+ on MacOS. The reason for fixing numpy
to old versions (e.g. 1.16.6) in the build dependencies was to ensure that the generated wheels for PyPI would work for anybody independently of the runtime numpy
version (old ones and new ones). If the wheels were built linking to a too new numpy
version (especially with numpy >= 1.20
), this would cause errors (or at least warnings) to users with numpy < 1.20
at runtime.
But based on what we have seen here, this is a no-go for MacOS users due to https://github.com/numpy/numpy/issues/18093, which was never fixed for numpy
version 1.16.6. So the approach of using "the-oldest-numpy-possible" seems ok for Windows and GNU/Linux, but for MacOS we need to relax it (>= instead of ==).
This issue is also a clear example of the importance of implementing a GitHub workflow for MacOS. Implementations for Windows and GNU/Linux are already available and building the official wheels for PyPI. The MacOS workflow is not implemented as of today and errors like the one that you addressed are only found when an end user shares it in the issue tracker.
@junchih Does it work for you if installing with the --no-use-pep517
flag, e.g. python -m pip install --no-use-pep517 basemap
?
@molinav, I got this error, and same error for python 3.9
$ python -m pip install --no-use-pep517 basemap
Collecting basemap
Using cached basemap-1.3.3.zip (155 kB)
ERROR: Disabling PEP 517 processing is invalid: project specifies a build backend of setuptools.build_meta in pyproject.toml
$ python --version
Python 3.8.9
@junchih Your issue was also mentioned in #547 and you were right with the source of the problem. The patch is already implemented in the develop
branch, so you can try out by doing:
python -m pip install https://github.com/matplotlib/basemap/archive/refs/heads/develop.zip#subdirectory=packages/basemap
and check that it works with:
python -c "from mpl_toolkits import basemap; print(basemap)"
The patch will arrive in PyPI with the hotfix version 1.3.4 of basemap
, which I hope to prepare soon.
Environment macOS Monterey Version 12.1 Chip Apple M1 Max Python 3.10.1
With the goes library as below
I tried to install basemap following the comments on #531
but installation failed with error
Even there exist header and built binary 'geos_c.h' and 'libgeos_c' in $GEOS_DIR