首页 > 解决方案 > pipenv 的问题

问题描述

我正在尝试创建一个虚拟环境。为此,我从终端安装 pipenv:

>pip install pipenv

没问题。

然后,当试图安装一个包,或者从 pipenv 做任何事情时,我做不到。

>pipenv install requests

错误:

pipenv : The term 'pipenv' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the 
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ pipenv install requests
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (pipenv:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

请帮我!我已经尝试过使用旧版本的 pipenv 包,但我不知道发生了什么。

标签: pythonpipenvpython-3.9

解决方案


利用python -m pip install requests

发生这种情况是因为系统中存储的 python 版本不同,并且与该版本关联的 pip 不同。

例如:在您的系统中,默认 python 可以是 2.7,python 3 版本可以是 3.6。它通过运行pythonpython3分别在终端中调用。

现在,如果您使用pip( pip install requests),那么它将在 python2.7 中安装请求,即 pip 关联的默认请求。

不使用 python3.6 安装,您需要调用与它关联的 pip pip3 install requests

所以这会造成混乱。因此,如果您使用 python 调用命令调用 pip 是一个好习惯,即python -m pip install <package name>

所以这会将包安装在您正在工作或想要工作的python环境中。


推荐阅读