“pipenv”不被识别为内部或外部命令、可操作程序或批处理文件

Win*_*ing 12 python windows pipenv

我是 python 的初学者,所以请温柔一点,如果你有答案,请提供详细信息。

在确保删除所有以前的安装(包括 anaconda)后,我刚刚安装了最新的 python 版本 3.10。我确信我的系统之前没有安装过任何内容。

安装 python 3.10 后,我打开终端并运行以下命令:

pip list
Run Code Online (Sandbox Code Playgroud)

其输出:

pip list
Package    Version
---------- -------
pip        21.2.3
setuptools 57.4.0
Run Code Online (Sandbox Code Playgroud)

然后我安装pipenv

pip install pipenv
Run Code Online (Sandbox Code Playgroud)

哪个输出

  WARNING: The script virtualenv-clone.exe is installed in 'C:\Users\Giulio\AppData\Roaming\Python\Python310\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script virtualenv.exe is installed in 'C:\Users\Giulio\AppData\Roaming\Python\Python310\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts pipenv-resolver.exe and pipenv.exe are installed in 'C:\Users\Giulio\AppData\Roaming\Python\Python310\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed backports.entry-points-selectable-1.1.0 certifi-2021.10.8 distlib-0.3.3 filelock-3.3.2 pipenv-2021.5.29 platformdirs-2.4.0 six-1.16.0 virtualenv-20.10.0 virtualenv-clone-0.5.7
Run Code Online (Sandbox Code Playgroud)

最后:

pipenv
'pipenv' is not recognized as an internal or external command,
operable program or batch file.
Run Code Online (Sandbox Code Playgroud)

现在我可以看到终端输出 3 个关于环境变量中未包含的路径的警告。我不明白为什么 Pipenv 安装在用户文件夹中。事实上,我的 python 安装位于 C:\Program Files 中(因为我确保在安装过程中进行了设置):

where python
C:\Program Files\Python310\python.exe
Run Code Online (Sandbox Code Playgroud)

如果我运行:

python -m pipenv
Run Code Online (Sandbox Code Playgroud)

Pipenv 做他的事。所以好吧,我决定像这样使用它(尽管所有教程都很简单)。我继续在给定文件夹中创建虚拟环境

python -m pipenv shell
Run Code Online (Sandbox Code Playgroud)

一切正常,我看到输出:

Successfully created virtual environment!
Virtualenv location: C:\Users\Giulio\.virtualenvs\project-dhMbrBv2
Run Code Online (Sandbox Code Playgroud)

最后,我检查 .virtualenvs 相关文件夹:

01/11/2021  10:58    <DIR>          .
01/11/2021  10:58    <DIR>          ..
01/11/2021  10:54                42 .gitignore
01/11/2021  10:54                38 .project
01/11/2021  10:58                 0 contents.txt
01/11/2021  10:54    <DIR>          Lib
01/11/2021  10:54               319 pyvenv.cfg
01/11/2021  10:54    <DIR>          Scripts
               4 File(s)            399 bytes
               4 Dir(s)  660,409,012,224 bytes free
Run Code Online (Sandbox Code Playgroud)

现在...不应该还有一个BIN文件夹吗?例如我想在 VSCode 中设置解释器。

我不明白为什么我会遇到所有这些小不一致。很高兴感谢任何帮助!

编辑(1):所以显然没有\bin文件夹,因为我使用的是 Windows:在 Windows 中,\Scripts而是创建了文件夹。但是如果没有抢占式调用 python,pipenv 无法运行的问题仍然存在。

小智 21

您可以参考此答案解决方案具有最高的赞成票 - Windows reports error when attempts to install package using pipelinenv

或者可以参考pipenv上的这个GitHub问题 - github链接

  1. 首先,删除当前版本的 virtualenv:pip uninstall virtualenv
  2. 然后,删除当前版本的 pipelinev:pip uninstall pipenv
  3. 当系统询问您是否继续(y/n)?只需输入 y。这会给你一个干净的记录。
  4. 最后,您可以再次安装 pipelinev 及其依赖项:pip install pipenv
  5. 检查安装情况pipenv --version