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

2024-03-08

我是 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

Finally:

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

一切正常,我看到输出:

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 无法运行的问题仍然存在。


您可以参考这个点赞数最高的答案解决方案 -尝试使用 Pipenv 安装软件包时 Windows 报告错误 https://stackoverflow.com/questions/46041719/windows-reports-error-when-trying-to-install-package-using-pipenv/46041892#46041892

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

  1. 首先,删除当前版本的 virtualenv:pip uninstall virtualenv
  2. 然后,删除当前版本的 pipelinev:pip uninstall pipenv
  3. 当系统询问您是否继续(y/n)?只需输入 y。这会给你一个干净的记录。
  4. 最后,您可以再次安装 pipelinev 及其依赖项:pip install pipenv
  5. 检查安装情况pipenv --version
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

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

随机推荐