即使安装了numpy,也显示未安装。我认为 venv 可能无法被 pip 访问(它应该是这样,因为 numpy 安装在 venv 内部),并且我使用
sudo apt install python3-numpy
在系统范围内安装了它,正如您在以下代码片段的最后一个中看到的那样。
vanangamudi@kaithadi:~/code/bec-gp/BEC_GP
$ workon gpinn
(gpinn) vanangamudi@kaithadi:~/code/bec-gp/BEC_GP
$ pip install trottersuzuki
Collecting trottersuzuki
Using cached trottersuzuki-1.6.2.tar.gz (218 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [20 lines of output]
Traceback (most recent call last):
File "/home/vanangamudi/.virtualenvs/gpinn/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/home/vanangamudi/.virtualenvs/gpinn/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vanangamudi/.virtualenvs/gpinn/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-d6cdwe1m/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 332, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-d6cdwe1m/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 302, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-d6cdwe1m/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 503, in run_setup
super().run_setup(setup_script=setup_script)
File "/tmp/pip-build-env-d6cdwe1m/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 318, in run_setup
exec(code, locals())
File "<string>", line 6, in <module>
ModuleNotFoundError: No module named 'numpy'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
(gpinn) vanangamudi@kaithadi:~/code/bec-gp/BEC_GP
$ python -c 'import numpy'
(gpinn) vanangamudi@kaithadi:~/code/bec-gp/BEC_GP
$ python -c 'import matplotlib'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'matplotlib'
(gpinn) vanangamudi@kaithadi:~/code/bec-gp/BEC_GP
$
您尝试安装的软件包的稳定版本,即 trottersuzuki 1.6.2 于 2017 年 3 月 29 日发布。您正在使用该软件包的最新版本的 Python,即 3.12。这可能会导致兼容性问题。
我浏览了 docs 和 PyPi 以找到它支持的特定 Python 版本,但对此并不清楚。即使有,也可能是旧版本,也许是 3.6。
您可能想使用替代包或将 Python 降级到版本 3.6,看看它是否有效。请记住,后者可能会影响其依赖项的功能,例如 numpy。