无法使用 Python 3.9 venv `pip install numpy`
Can't `pip install numpy` with a Python 3.9 venv
我安装了 Python 3.9,创建了一个 venv
并尝试安装 numpy。 Cython 有一个错误,已在主干中修复。
所以我安装了 venv Cython 3.0a0 并重试:
(venv) marco@buzz:~/sources/cython$ pip install numpy --no-cache-dir
[...]
Collecting Cython>=0.29.13
[...]
ERROR: Command errored out with exit status 1:
/home/marco/sources/tests/more_itertools/venv/bin/python3.9
/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip
install --ignore-installed --no-user --prefix
/tmp/pip-build-env-3ctn3kl8/overlay --no-warn-script-location
--no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel 'Cython>=0.29.13' Check the logs for full command
output.
所以我尝试在函数def install_requirements
中注释掉venv/lib/python3.9/site-packages/pip/_internal/build_env.py
中的--ignore-installed
。我收到此错误:
ERROR: Exception:
Traceback (most recent call last):
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 153, in _main
status = self.run(options, args)
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 382, in run
resolver.resolve(requirement_set)
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/legacy_resolve.py", line 201, in resolve
self._resolve_one(requirement_set, req)
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/legacy_resolve.py", line 365, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/legacy_resolve.py", line 312, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 223, in prepare_linked_requirement
abstract_dist = _get_prepared_distribution(
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 49, in _get_prepared_distribution
abstract_dist.prepare_distribution_metadata(finder, build_isolation)
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/distributions/source/legacy.py", line 37, in prepare_distribution_metadata
self._setup_isolation(finder)
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/distributions/source/legacy.py", line 90, in _setup_isolation
reqs = backend.get_requires_for_build_wheel()
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_vendor/pep517/wrappers.py", line 151, in get_requires_for_build_wheel
return self._call_hook('get_requires_for_build_wheel', {
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_vendor/pep517/wrappers.py", line 255, in _call_hook
raise BackendUnavailable(data.get('traceback', ''))
pip._vendor.pep517.wrappers.BackendUnavailable: Traceback (most recent call last):
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 63, in _build_backend
obj = import_module(mod_path)
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1016, in _gcd_import
File "<frozen importlib._bootstrap>", line 993, in _find_and_load
File "<frozen importlib._bootstrap>", line 963, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1016, in _gcd_import
File "<frozen importlib._bootstrap>", line 993, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'setuptools'
所以我手动安装了依赖项并尝试 --no-deps
:
(venv) marco@buzz:~/sources/tests/more_itertools/venv$ pip install numpy --no-deps
Collecting numpy
Using cached https://files.pythonhosted.org/packages/31/0a/5df350c29a06835d534a6c4f5681075304da38d85f1c69e5226a635a67ce/numpy-1.18.0.zip
Installing build dependencies ... error
[...]
和以前一样的错误。 --no-deps
被忽略,并且 --ignore-installed
强制从 Pypi 下载 Cython,这不适用于 Python 3.9.
显然,没有 --no-ignore-installed
或 --ignore-installed=0
。以及
的事实
pip
忽略 --no-deps
- 如果在
venv
中注释掉--ignore-installed
,pip
找不到已经安装的模块
我在老 easy_install
上取得了成功,所以我认为现在还不错。我会报告这个错误(我猜是 venv
开发者)。
我安装了 Python 3.9,创建了一个 venv
并尝试安装 numpy。 Cython 有一个错误,已在主干中修复。
所以我安装了 venv Cython 3.0a0 并重试:
(venv) marco@buzz:~/sources/cython$ pip install numpy --no-cache-dir
[...]
Collecting Cython>=0.29.13
[...]
ERROR: Command errored out with exit status 1: /home/marco/sources/tests/more_itertools/venv/bin/python3.9 /home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-3ctn3kl8/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel 'Cython>=0.29.13' Check the logs for full command output.
所以我尝试在函数def install_requirements
中注释掉venv/lib/python3.9/site-packages/pip/_internal/build_env.py
中的--ignore-installed
。我收到此错误:
ERROR: Exception:
Traceback (most recent call last):
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 153, in _main
status = self.run(options, args)
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 382, in run
resolver.resolve(requirement_set)
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/legacy_resolve.py", line 201, in resolve
self._resolve_one(requirement_set, req)
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/legacy_resolve.py", line 365, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/legacy_resolve.py", line 312, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 223, in prepare_linked_requirement
abstract_dist = _get_prepared_distribution(
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 49, in _get_prepared_distribution
abstract_dist.prepare_distribution_metadata(finder, build_isolation)
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/distributions/source/legacy.py", line 37, in prepare_distribution_metadata
self._setup_isolation(finder)
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_internal/distributions/source/legacy.py", line 90, in _setup_isolation
reqs = backend.get_requires_for_build_wheel()
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_vendor/pep517/wrappers.py", line 151, in get_requires_for_build_wheel
return self._call_hook('get_requires_for_build_wheel', {
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_vendor/pep517/wrappers.py", line 255, in _call_hook
raise BackendUnavailable(data.get('traceback', ''))
pip._vendor.pep517.wrappers.BackendUnavailable: Traceback (most recent call last):
File "/home/marco/sources/tests/more_itertools/venv/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 63, in _build_backend
obj = import_module(mod_path)
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1016, in _gcd_import
File "<frozen importlib._bootstrap>", line 993, in _find_and_load
File "<frozen importlib._bootstrap>", line 963, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1016, in _gcd_import
File "<frozen importlib._bootstrap>", line 993, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'setuptools'
所以我手动安装了依赖项并尝试 --no-deps
:
(venv) marco@buzz:~/sources/tests/more_itertools/venv$ pip install numpy --no-deps
Collecting numpy
Using cached https://files.pythonhosted.org/packages/31/0a/5df350c29a06835d534a6c4f5681075304da38d85f1c69e5226a635a67ce/numpy-1.18.0.zip
Installing build dependencies ... error
[...]
和以前一样的错误。 --no-deps
被忽略,并且 --ignore-installed
强制从 Pypi 下载 Cython,这不适用于 Python 3.9.
显然,没有 --no-ignore-installed
或 --ignore-installed=0
。以及
pip
忽略--no-deps
- 如果在
venv
中注释掉--ignore-installed
,pip
找不到已经安装的模块
我在老 easy_install
上取得了成功,所以我认为现在还不错。我会报告这个错误(我猜是 venv
开发者)。