我是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
一切正常,我看到了输出:
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
文件夹。
但是,pipenv在没有预先调用Python的情况下无法运行的问题仍然存在。