Open wangjoshuah opened 2 years ago
I think if we bump the numpy
dependency to >=1.20.0
It will automatically pickup a numpy
wheel with arm64 support.
Edit: my original comment below installs tslearn
without error, but then there is an error when doing an import, like from tslearn.clustering import TimeSeriesKMeans
, similar to what is mentioned in #419. The error is
Traceback (most recent call last):
File "__init__.pxd", line 942, in numpy.import_array
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/me/opt/miniconda3/envs/tsl/lib/python3.10/site-packages/tslearn/clustering/__init__.py", line 8, in <module>
from .kshape import KShape
File "/Users/me/opt/miniconda3/envs/tsl/lib/python3.10/site-packages/tslearn/clustering/kshape.py", line 11, in <module>
from tslearn.metrics import cdist_normalized_cc, y_shifted_sbd_vec
File "/Users/me/opt/miniconda3/envs/tsl/lib/python3.10/site-packages/tslearn/metrics/__init__.py", line 19, in <module>
from .softdtw_variants import (cdist_soft_dtw, cdist_gak,
File "/Users/me/opt/miniconda3/envs/tsl/lib/python3.10/site-packages/tslearn/metrics/softdtw_variants.py", line 12, in <module>
from .soft_dtw_fast import _soft_dtw, _soft_dtw_grad, \
File "tslearn/metrics/soft_dtw_fast.pyx", line 11, in init tslearn.metrics.soft_dtw_fast
File "__init__.pxd", line 944, in numpy.import_array
ImportError: numpy.core.multiarray failed to import
The same thing happens when installing with
python -m pip install https://github.com/tslearn-team/tslearn/archive/main.zip
I've tried Python versions 3.8.13, 3.9.12, and 3.10.4. Upgrading pip and uninstalling and reinstalling numpy version 1.22.4 did not resolve the problem.
Original comment:
I have the same problem when trying to install v0.5.2 on an M1 Mac. A workaround is to install from the repository:
pip install git+https://github.com/tslearn-team/tslearn
This commit removed the numpy<=1.19 requirement, but it hasn't been released in an updated version, so I don't think it's on PyPI yet.
Installing from the GitHub repository with the below command also leads to importing errors on my older, Intel Mac.
python -m pip install -v https://github.com/tslearn-team/tslearn/archive/main.zip
I believe the problem is that numpy-1.23.2 is installed as the build dependency, but numpy-1.22.4 is installed as the runtime dependency. By this, I mean that numpy-1.23.2 is used in setup.py
, such as in these lines
include_dirs=[numpy.get_include()],
ext_modules=cythonize("tslearn/metrics/*.pyx",
include_path=[numpy.get_include()]),
but then numpy-1.22.4 is installed in the user’s environment, so that when the user is running Python and importing tslearn, they are using numpy-1.22.4. I believe this is the source of the error noted above: “RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf”
pyproject.toml
only specifies “numpy”, so the latest version is used to build tslearn. For the runtime dependencies, numba doesn’t support numpy 1.23 yet, so 1.22.4 is installed.
I was able to get things working by updating pyproject.toml
to
[build-system]
requires = ["setuptools", "wheel", "numpy<1.23", "Cython"]
However, I’m not sure this is the best fix since it would probably need to be updated again once numba supports numpy 1.23.
Another fix, which is suggested in this pip issue is to use “oldest-supported-numpy” in pyproject.toml
:
[build-system]
requires = ["setuptools", "wheel", "oldest-supported-numpy", "Cython"]
This works on both my Intel and M1 MacBooks.
@rtavenar Would you be receptive to a PR that makes the above changes to pyproject.toml
to address this issue?
Doesn't seem like a complicated fix. Could someone please explain the holdup and if I could help in any way to speed things up? @DanielKerrigan @wangjoshuah
Describe the bug I cannot install
tslearn
on Apple Silicon M1. It's trying to gathernumpy >= 1.19.0
which does not yet have automatic support for M1. But as of version 1.20 they include automatic support for M1 I believe.To Reproduce Poetry install with tslearn as a dependency
Expected behavior Successful install
Environment (please complete the following information):
Additional context Add any other context about the problem here.