繁体   English   中英

'pipenv' 不是内部或外部命令、可运行程序或批处理文件

[英]'pipenv' is not recognized as an internal or external command, operable program or batch file

我是 python 的初学者,所以请保持温和,如果您有答案,请提供详细信息。

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

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

pip list

输出:

pip list
Package    Version
---------- -------
pip        21.2.3
setuptools 57.4.0

然后我安装 pipenv

pip install pipenv

哪个输出

  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

最后:

pipenv
'pipenv' is not recognized as an internal or external command,
operable program or batch file.

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

where python
C:\Program Files\Python310\python.exe

如果我运行:

python -m pipenv

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

python -m pipenv shell

一切正常,我看到 output:

Successfully created virtual environment!
Virtualenv location: C:\Users\Giulio\.virtualenvs\project-dhMbrBv2

最后,我检查了 .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

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

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

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

您可以参考this answer solution with the most upvotes - Windows 在尝试使用 pipenv 安装软件包时报告错误

或参考 pipenv 上的这个 GitHub 问题 - https://github.com/pypa/pipenv/issues/3101

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

如果您有能力重新安装 python,请运行从 python 站点下载的安装程序并选中“将 python X.XX 添加到 PATH”复选框并完成安装。在这里完成

确实按照建议的步骤操作,但没有用,后来,将“C:\Users\xxxxxxx\AppData\Roaming\Python\Python310\Scripts”设置为“PATH”环境变量并重新启动 cmd。

它就像一个魅力......注意:在安装过程中,它会警告将“C:\Users\xxxxxxx\AppData\Roaming\Python\Python310\Scripts”设置为“PAHT”环境变量

  1. Go 到控制面板中的高级系统设置
  2. 点击环境变量
  3. 在系统变量下查找 PATH(如果您没有看到它,那么您可以单击新建并创建一个)。
  4. 单击编辑并在变量值粘贴链接中看起来像这样 C:\Users\xxxxxxx\AppData\Roaming\Python\Python310\Scripts
  5. 点击确定

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM