我试着用pipenv。我运行命令pip install pipenv,运行成功:

...
Successfully built pipenv pathlib shutilwhich pythonz-bd virtualenv-clone
Installing collected packages: virtualenv, pathlib, shutilwhich, backports.shutil-get-terminal-size, pythonz-bd, virtualenv-clone, pew, first, six, click, pip-tools, certifi, chardet, idna, urllib3, requests, pipenv
...

但是,当我在一个新的根项目目录中运行命令pipenv install时,我收到以下消息:-bash: pipenv: command not found。我怀疑我可能需要修改我的.bashrc,但我不清楚该向文件中添加什么,或者修改是否有必要。


当前回答

这为我解决了问题:

sudo -H pip install -U pipenv

其他回答

如何使pipenv一个基本命令

使用Python3的Pipenv需要以“$ python -m Pipenv[命令]”或“$ Python3 -m Pipenv[命令]”的方式运行;开头的"python"命令根据你在shell中激活python的方式而有所不同。修复并设置为"$ pipenv[命令]":[Git Bash中的示例]

$ cd ~
$ code .bash_profile

第一行是必要的,因为它允许您访问.bash_profile文件。第二行在VSCode中打开.bash_profile,因此插入默认代码编辑器的命令。 在这一点上,你会想要(在.bash_profile中)编辑文件,添加这行代码:

alias pipenv='python -m pipenv'

然后保存文件并在Git Bash中输入:

$ source .bash_profile

然后你可以在任何地方使用pipenv作为命令,例如: $ pipenv shell 将工作。

这种使用方法适用于在Git Bash中创建命令。例如:

alias python='winpty python.exe'

在.bash_profile中输入: $ source .bash_profile 将允许Python以“Python”的形式运行。

不客气

在安装pipenv (sudo pip install pipenv)后,当试图运行pipenv shell命令时,我一直得到“Command Not Found”错误。

我最终用以下代码修复了它:

pip3 install pipenv
pipenv shell

这简单地解决了我的问题,如果你是在窗口。

pip install pipenv

其次,在以下路径中替换您的<用户名>,并将其添加到PATH环境变量中:

c:\Users\<username>\AppData\Roaming\Python\Python38\Site-Packages
C:\Users\<username>\AppData\Roaming\Python\Python38\Scripts

您需要关闭命令提示符并重新打开它。 第三,输入以下命令检查pipenv是否正确安装:

pipenv -h

我希望这对你也有帮助!

对于那些使用sudo pip3安装它的pipenv,则需要使用python3 -m pipenv shell或python3.9 -m pipenv shell

以下是我在Mac OSX上成功解决“Pipenv: Command Not Found”问题的方法

您应该将这些目录的所有权更改为您的用户。 sudo chown -R $(whoami) /usr/local/share 请确保您的用户具有写权限。 Chmod u+w /usr/local/share 然后考虑使用Homebrew安装: 酿造更新 酿造安装pyenv