我有一个 requirement.txt 看起来像,
# ~/projects/pip-env-test/requirement.txt
Django==2.2
现在我运行了命令,pipenv install -r requirements.txt --python 3.6
现在我得到了错误,
[pipenv.exceptions.InstallError]: ERROR: No matching distribution found for django==2.2
我们知道,Django==2.2 在那里,--python 3.6
标志似乎没有被 pipenv
命令使用.
complete error traceback
% pipenv install -r requirements.txt --python 3.6 !7968
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Creating a Pipfile for this project…
Requirements file provided! Importing into Pipfile…
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Building requirements...
Resolving dependencies...
✔ Success!
Updated Pipfile.lock (0a73ee)!
Installing dependencies from Pipfile.lock (0a73ee)…
🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 1/1 — 00:00:00
An error occurred while installing django==2.2 --hash=sha256:7c3543e4fb070d14e10926189a7fcf42ba919263b7473dceaefce34d54e8a119 --hash=sha256:a2814bffd1f007805b19194eb0b9a331933b82bd5da1c3ba3d7b7ba16e06dc4b! Will try again.
Installing initially failed dependencies…
[InstallError]: File "/home/jpg/.local/lib/python3.6/site-packages/pipenv/cli/command.py", line 252, in install
[InstallError]: site_packages=state.site_packages
[InstallError]: File "/home/jpg/.local/lib/python3.6/site-packages/pipenv/core.py", line 2062, in do_install
[InstallError]: keep_outdated=keep_outdated
[InstallError]: File "/home/jpg/.local/lib/python3.6/site-packages/pipenv/core.py", line 1314, in do_init
[InstallError]: pypi_mirror=pypi_mirror,
[InstallError]: File "/home/jpg/.local/lib/python3.6/site-packages/pipenv/core.py", line 901, in do_install_dependencies
[InstallError]: retry_list, procs, failed_deps_queue, requirements_dir, **install_kwargs
[InstallError]: File "/home/jpg/.local/lib/python3.6/site-packages/pipenv/core.py", line 796, in batch_install
[InstallError]: _cleanup_procs(procs, failed_deps_queue, retry=retry)
[InstallError]: File "/home/jpg/.local/lib/python3.6/site-packages/pipenv/core.py", line 703, in _cleanup_procs
[InstallError]: raise exceptions.InstallError(c.dep.name, extra=err_lines)
[pipenv.exceptions.InstallError]: DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
[pipenv.exceptions.InstallError]: ERROR: Could not find a version that satisfies the requirement django==2.2 (from -r /tmp/pipenv-txy_9wyg-requirements/pipenv-aq47p_5k-requirement.txt (line 1)) (from versions: 1.1.3, 1.1.4, 1.2, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.2.6, 1.2.7, 1.3, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.3.6, 1.3.7, 1.4, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.4.8, 1.4.9, 1.4.10, 1.4.11, 1.4.12, 1.4.13, 1.4.14, 1.4.15, 1.4.16, 1.4.17, 1.4.18, 1.4.19, 1.4.20, 1.4.21, 1.4.22, 1.5, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.5.9, 1.5.10, 1.5.11, 1.5.12, 1.6, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.6.7, 1.6.8, 1.6.9, 1.6.10, 1.6.11, 1.7, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.7.8, 1.7.9, 1.7.10, 1.7.11, 1.8a1, 1.8b1, 1.8b2, 1.8rc1, 1.8, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.8.5, 1.8.6, 1.8.7, 1.8.8, 1.8.9, 1.8.10, 1.8.11, 1.8.12, 1.8.13, 1.8.14, 1.8.15, 1.8.16, 1.8.17, 1.8.18, 1.8.19, 1.9a1, 1.9b1, 1.9rc1, 1.9rc2, 1.9, 1.9.1, 1.9.2, 1.9.3, 1.9.4, 1.9.5, 1.9.6, 1.9.7, 1.9.8, 1.9.9, 1.9.10, 1.9.11, 1.9.12, 1.9.13, 1.10a1, 1.10b1, 1.10rc1, 1.10, 1.10.1, 1.10.2, 1.10.3, 1.10.4, 1.10.5, 1.10.6, 1.10.7, 1.10.8, 1.11a1, 1.11b1, 1.11rc1, 1.11, 1.11.1, 1.11.2, 1.11.3, 1.11.4, 1.11.5, 1.11.6, 1.11.7, 1.11.8, 1.11.9, 1.11.10, 1.11.11, 1.11.12, 1.11.13, 1.11.14, 1.11.15, 1.11.16, 1.11.17, 1.11.18, 1.11.20, 1.11.21, 1.11.22, 1.11.23, 1.11.24, 1.11.25, 1.11.26, 1.11.27, 1.11.28, 1.11.29)
[pipenv.exceptions.InstallError]: ERROR: No matching distribution found for django==2.2 (from -r /tmp/pipenv-txy_9wyg-requirements/pipenv-aq47p_5k-requirement.txt (line 1))
ERROR: Couldn't install package: django
Package installation failed...
☤ ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/1 — 00:00:00
注意:我目前使用的是pipenv==2020.6.2
更新-1
我尝试运行相同的命令,之后
- 退出虚拟环境
- 删除
Pipfile
和Pipfile.lock
但是,我又遇到了一个错误,
% pipenv install -r requirements.txt --python 3.6 !7979
Creating a virtualenv for this project…
Pipfile: /home/jpg/projects/pip-env-test/Pipfile
Using /usr/bin/python3.6m (3.6.9) to create virtualenv…
⠹ Creating virtual environment...ImportError: cannot import name 'ensure_file_on_disk'
✘ Failed creating virtual environment
[pipenv.exceptions.VirtualenvCreationException]:
Failed to create virtual environment.
最佳答案
您的日志显示您使用的是 Python 2.7,即 EOL:
[pipenv.exceptions.InstallError]: DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020.
Django 2.x+ 根本不支持 Python 2(从日志中可以看出,适用于 Python 2 的 Django 版本为 1.1.3、[...]、1.11.27、1.11.28、1.11 .29).
这就是为什么不可能在 Python 2.x 上满足 Django 2.2 的要求。
关于python - [pipenv.exceptions.InstallError] : ERROR: Could not find a version that satisfies the requirement django==2. 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63280449/