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