Alpine (Docker) 装 NumPy 报错:
pip install numpy
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [50 lines of output]
+ /usr/local/bin/python /tmp/pip-install-gx5eqniw/numpy_7aed40719f464985838e9f98ec3fad5b/vendored-meson/meson/meson.py setup /tmp/pip-install-gx5eqniw/numpy_7aed40719f464985838e9f98ec3fad5b /tmp/pip-install-gx5eqniw/numpy_7aed40719f464985838e9f98ec3fad5b/.mesonpy-lzr0zolk/build -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/tmp/pip-install-gx5eqniw/numpy_7aed40719f464985838e9f98ec3fad5b/.mesonpy-lzr0zolk/build/meson-python-native-file.ini
The Meson build system
Version: 1.2.99
Source dir: /tmp/pip-install-gx5eqniw/numpy_7aed40719f464985838e9f98ec3fad5b
Build dir: /tmp/pip-install-gx5eqniw/numpy_7aed40719f464985838e9f98ec3fad5b/.mesonpy-lzr0zolk/build
Build type: native build
Project name: NumPy
Project version: 1.26.1
C compiler for the host machine: cc (gcc 13.2.1 "cc (Alpine 13.2.1_git20240309) 13.2.1 20240309")
C linker for the host machine: cc ld.bfd 2.42
C++ compiler for the host machine: c++ (gcc 13.2.1 "c++ (Alpine 13.2.1_git20240309) 13.2.1 20240309")
C++ linker for the host machine: c++ ld.bfd 2.42
Cython compiler for the host machine: cython (cython 3.0.10)
Host machine cpu family: aarch64
Host machine cpu: aarch64
Program python found: YES (/usr/local/bin/python)
Found pkg-config: /usr/bin/pkg-config (2.2.0)
Run-time dependency python found: YES 3.10
Has header "Python.h" with dependency python-3.10: YES
Compiler for C supports arguments -fno-strict-aliasing: YES
Message: During parsing cpu-dispatch: The following CPU features were ignored due to platform incompatibility or lack of support:
"XOP FMA4"
Test features "NEON NEON_FP16 NEON_VFPV4 ASIMD" : Supported
Test features "ASIMDHP" : Supported
Test features "ASIMDFHM" : Supported
Configuring npy_cpu_dispatch_config.h using configuration
Message:
CPU Optimization Options
baseline:
Requested : min
Enabled : NEON NEON_FP16 NEON_VFPV4 ASIMD
dispatch:
Requested : max -xop -fma4
Enabled : ASIMDHP ASIMDFHM
Library m found: YES
Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency scipy-openblas found: NO (tried pkgconfig and cmake)
Run-time dependency mkl found: NO (tried pkgconfig and system)
Run-time dependency mkl found: NO (tried pkgconfig and system)
Run-time dependency accelerate found: NO (tried system)
Run-time dependency openblas found: NO (tried pkgconfig, pkgconfig, pkgconfig, system and cmake)
Run-time dependency flexiblas found: NO (tried pkgconfig and cmake)
Run-time dependency blis found: NO (tried pkgconfig and cmake)
Run-time dependency blas found: NO (tried pkgconfig and cmake)
../../numpy/meson.build:169:4: ERROR: Problem encountered: No BLAS library detected! Install one, or use the `allow-noblas` build option (note, this may be up to 100x slower for some linear algebra operations).
A full log can be found at /tmp/pip-install-gx5eqniw/numpy_7aed40719f464985838e9f98ec3fad5b/.mesonpy-lzr0zolk/build/meson-logs/meson-log.txt
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
再加粗的那行可以看到是没有blas,但是在我装上blas-dev和lapack-dev之后,虽然能成功装上numpy,在python中导入的时候却会报错:
>>> import numpy
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/numpy/core/__init__.py", line 24, in <module>
from . import multiarray
File "/usr/local/lib/python3.10/site-packages/numpy/core/multiarray.py", line 10, in <module>
from . import overrides
File "/usr/local/lib/python3.10/site-packages/numpy/core/overrides.py", line 8, in <module>
from numpy.core._multiarray_umath import (
ImportError: Error relocating /usr/local/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-aarch64-linux-gnu.so: cblas_dsyrk: symbol not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/numpy/__init__.py", line 130, in <module>
from numpy.__config__ import show as show_config
File "/usr/local/lib/python3.10/site-packages/numpy/__config__.py", line 4, in <module>
from numpy.core._multiarray_umath import (
File "/usr/local/lib/python3.10/site-packages/numpy/core/__init__.py", line 50, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.10 from "/usr/local/bin/python3"
* The NumPy version is: "1.26.1"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: Error relocating /usr/local/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-aarch64-linux-gnu.so: cblas_dsyrk: symbol not found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.10/site-packages/numpy/__init__.py", line 135, in <module>
raise ImportError(msg) from e
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there.
最后我改为使用openblas-dev,然后重新安装numpy就成功了:
apk add openblas-dev
pip uninstall numpy
pip install numpy