在一个处理器架构为armv7l的电视盒子上面,想要使用看klipper的共振补偿功能,出现了下面的问题:
klipper@voron02 [~] ➜ pip3 install numpy [20:09:50]
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting numpy
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/a9/75/10dd1f8116a8b796cb2c737b674e02d02e80454bda953fa7e65d8c12b016/numpy-2.0.2.tar.gz (18.9 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 /usr/lib/python3/dist-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-c6a775oq/normal --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.tuna.tsinghua.edu.cn/simple -- 'patchelf >= 0.11.0' 'ninja >= 1.8.2'
cwd: None
Complete output (35 lines):
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting patchelf>=0.11.0
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/69/47/e02357d1075cdf4b56be39a6c218a5a2b0bd3896011120ae3765190ab527/patchelf-0.17.2.1-py2.py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.musllinux_1_1_armv7l.whl (381 kB)
Collecting ninja>=1.8.2
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/37/2c/d717d13a413d6f7579cdaa1e28e6e2c98de95461549b08d311c8a5bf4c51/ninja-1.11.1.1.tar.gz (132 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing wheel metadata: started
Preparing wheel metadata: finished with status 'done'
Building wheels for collected packages: ninja
Building wheel for ninja (PEP 517): started
Building wheel for ninja (PEP 517): finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 /tmp/tmp699h8fkz_in_process.py build_wheel /tmp/tmptord55ww
cwd: /tmp/pip-install-mrz_ktfi/ninja
Complete output (13 lines):
/tmp/pip-build-env-20tp_b_7/overlay/lib/python3.9/site-packages/setuptools_scm/git.py:312: UserWarning: git archive did not support describe output
warnings.warn("git archive did not support describe output")
/tmp/pip-build-env-20tp_b_7/overlay/lib/python3.9/site-packages/setuptools_scm/git.py:331: UserWarning: unprocessed git archival found (no export subst applied)
warnings.warn("unprocessed git archival found (no export subst applied)")
Traceback (most recent call last):
File "/tmp/pip-build-env-20tp_b_7/overlay/lib/python3.9/site-packages/skbuild/setuptools_wrap.py", line 639, in setup
cmkr = cmaker.CMaker(cmake_executable)
File "/tmp/pip-build-env-20tp_b_7/overlay/lib/python3.9/site-packages/skbuild/cmaker.py", line 145, in __init__
self.cmake_version = get_cmake_version(self.cmake_executable)
File "/tmp/pip-build-env-20tp_b_7/overlay/lib/python3.9/site-packages/skbuild/cmaker.py", line 102, in get_cmake_version
raise SKBuildError(msg) from err
Problem with the CMake installation, aborting build. CMake executable is cmake
----------------------------------------
ERROR: Failed building wheel for ninja
Failed to build ninja
ERROR: Could not build wheels for ninja which use PEP 517 and cannot be installed directly
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 /usr/lib/python3/dist-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-c6a775oq/normal --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.tuna.tsinghua.edu.cn/simple -- 'patchelf >= 0.11.0' 'ninja >= 1.8.2' Check the logs for full command output.
主要的问题体现在最后几行:错误为:
无法为 ninja 构建 wheel
无法构建 ninja
错误:无法为使用 PEP 517 且无法直接安装的 ninja 构建 wheel
总之就是很难编译成功,尝试了很多次都无法实现
研究了好久,有一个最快的解决方法,最新版本的numpy2.0.2是无法正常安装的,通过pip直接安装旧版本比如1.21.2就行:
pip install numpy==1.21.2
因为配置垃圾,只有1G的RAM。安装了接近半个小时,以下是安装过程:
klipper@voron02 [~] ➜ pip install numpy==1.21.2 [20:31:11]
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting numpy==1.21.2
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3a/be/650f9c091ef71cb01d735775d554e068752d3ff63d7943b26316dc401749/numpy-1.21.2.zip (10.3 MB)
|████████████████████████████████| 10.3 MB 78 kB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: numpy
Building wheel for numpy (PEP 517) ... done
Created wheel for numpy: filename=numpy-1.21.2-cp39-cp39-linux_armv7l.whl size=16991788 sha256=928b0f6182d50ebb5de52e20f2534a7c7487516006f2623892065b7a5e682f63
Stored in directory: /home/klipper/.cache/pip/wheels/db/b6/7f/1c23e80e91c6acd530503de07c9185c3254209f9d3d6387610
Successfully built numpy
Installing collected packages: numpy
WARNING: The scripts f2py, f2py3 and f2py3.9 are installed in '/home/klipper/.local/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 numpy-1.21.2
除此之外,大部分的klipper是建立了虚拟的环境,如果网页客户端的Mainsail或者Fluidd要求你使用虚拟环境的安装,也就是改一个东西的事情:
~/klippy-env/bin/pip install numpy==1.21.2
等等!!假如你刚好忘记在虚拟环境里面安装,甚至可以在外面的python环境安装好了numpy后再移动过去(不建议,但还是可以用),如果无法移动则需要将下面的代码修改成你自己的python路径:
cp -rf ~/.local/lib/python3.9/site-packages/numpy ~/klippy-env/lib/python3.9/site-packages
cp -rf ~/.local/lib/python3.9/site-packages/numpy-1.21.2.dist-info ~/klippy-env/lib/python3.9/site-packages
总之,无法在armv7l上正常安装python numpy库的原因就是版本太高,编译失败,对于不是要用到高版本的功能,装个旧版本就行了,肯定也不要装太旧了,对于python3.9,numpy的版本1.21.2就行了。