我正在尝试运行命令
pipenv install python==3.7.9
并收到以下错误。当我跑
which python
显示“/Users/Micky/opt/anaconda3/bin/python”,版本为3.7.9。
谁能告诉我怎么做?
Micky-MBP:sportanalitica Micky$ pipenv install python==3.7.9
Installing python==3.7.9...
Error: An error occurred while installing python==3.7.9!
Error text:
ERROR: Could not find a version that satisfies the requirement python==3.7.9
ERROR: No matching distribution found for python==3.7.9
✘ Installation Failed
答案 0 :(得分:0)
Pipenv 不用于安装 Python 版本。您单独安装 Python,然后使用 Pipenv 创建和管理虚拟环境,使用 pipenv install <package>
安装 Python 包。
我认为您要做的是创建一个使用您的 Python 3.7.9 版本的虚拟环境。为此,指定 Python 版本的正确方法是将其作为 --python=</path/to/python>
选项传递。例如,对于 pipenv shell
:
~$ pipenv shell --help
Usage: pipenv shell [OPTIONS] [SHELL_ARGS]...
Spawns a shell within the virtualenv.
Options:
...
--python TEXT Specify which version of Python virtualenv should use.
同样的选项可用于 pipenv install
。因此,如果您有“python3 指向 /Users/Micky/opt/anaconda3/bin/python”:
~$ pipenv shell --python=/Users/Micky/opt/anaconda3/bin/python
请注意,您必须仅在创建虚拟环境时传递 --python
选项。创建后,它会在 Pipfile 中“记住”它以使用该版本。
temp$ pipenv shell --python=/usr/local/opt/python@3.7/bin/python3
...
✔ Successfully created virtual environment!
...
Creating a Pipfile for this project...
Launching subshell in virtual environment...
...
(temp) temp$ python -V
Python 3.7.9
一旦你的虚拟环境,你使用 pipenv install <package>
来安装 Python 包(不是 Python 本身):
(temp) temp$ pipenv install somepackage
(temp) temp$ pipenv install somepackage==1.0.0
答案 1 :(得分:0)
据我所知,我了解您希望在您的 Pipenv 中使用特定版本的 Python。看起来您传递参数的方式是错误的。您传递的参数更多是针对包而不是 Python 版本。