python 的 pipenv 安装包不起作用

pipenv install packages for python is not working

我是 Python 的新手,因此我正在努力解决以下问题。我安装了 pip 并进行了 pipenv 的用户安装,然后在我的项目文件夹中 运行 命令:

pipenv install requests

这给了我一个错误,说 pipenv 命令错误或找不到

我在我的系统环境变量中添加了以下路径:

C:\Users\andri\AppData\Roaming\Python\Python37\Scripts

但还是不行。有谁知道我下一步应该做什么来解决这个问题?提前致谢

更新:

我的操作系统是Windows。

下面是我通过cmd安装pip的方法


C:\Users\andri>python -m pip install -U pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828dfc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 1.5MB/s
Installing collected packages: pip
  Found existing installation: pip 18.1
    Uninstalling pip-18.1:
      Successfully uninstalled pip-18.1
Successfully installed pip-19.0.3

C:\Users\andri>pipenv install requests
Der Befehl "pipenv" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

C:\Users\andri>pip --version
pip 19.0.3 from c:\users\andri\appdata\local\programs\python\python37-32\lib\site-packages\pip (python 3.7)

C:\Users\andri>pip install --user pipenv
Collecting pipenv
  Downloading https://files.pythonhosted.org/packages/13/b4/3ffa55f77161cff9a5220f162670f7c5eb00df52e00939e203f601b0f579/pipenv-2018.11.26-py3-none-any.whl (5.2MB)
    100% |████████████████████████████████| 5.2MB 2.2MB/s
Requirement already satisfied: setuptools>=36.2.1 in c:\users\andri\appdata\local\programs\python\python37-32\lib\site-packages (from pipenv) (40.6.2)
Collecting virtualenv-clone>=0.2.5 (from pipenv)
  Downloading https://files.pythonhosted.org/packages/e3/d9/d9c56deb483c4d3289a00b12046e41428be64e8236fa210111a1f57cc42d/virtualenv_clone-0.5.1-py2.py3-none-any.whl
Collecting virtualenv (from pipenv)
  Downloading https://files.pythonhosted.org/packages/33/5d/314c760d4204f64e4a968275182b7751bd5c3249094757b39ba987dcfb5a/virtualenv-16.4.3-py2.py3-none-any.whl (2.0MB)
    100% |████████████████████████████████| 2.0MB 4.7MB/s
Requirement already satisfied: pip>=9.0.1 in c:\users\andri\appdata\local\programs\python\python37-32\lib\site-packages (from pipenv) (19.0.3)
Collecting certifi (from pipenv)
  Downloading https://files.pythonhosted.org/packages/60/75/f692a584e85b7eaba0e03827b3d51f45f571c2e793dd731e598828d380aa/certifi-2019.3.9-py2.py3-none-any.whl (158kB)
    100% |████████████████████████████████| 163kB 837kB/s
Installing collected packages: virtualenv-clone, virtualenv, certifi, pipenv
  The script virtualenv-clone.exe is installed in 'C:\Users\andri\AppData\Roaming\Python\Python37\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.
  The script virtualenv.exe is installed in 'C:\Users\andri\AppData\Roaming\Python\Python37\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.
  The scripts pipenv-resolver.exe and pipenv.exe are installed in 'C:\Users\andri\AppData\Roaming\Python\Python37\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 certifi-2019.3.9 pipenv-2018.11.26 virtualenv-16.4.3 virtualenv-clone-0.5.1
  The script virtualenv.exe is installed in 'C:\Users\andri\AppData\Roaming\Python\Python37\Scripts' which is not on PATH.
  Consider adding this directory to PATH

有你的答案。 Scripts 包含为每个用户安装的软件包的实用脚本的目录不在 PATH 上,因此除非您添加它,否则您的命令 shell 将找不到它们。

如果您 只是 通过控制面板将其添加到 PATH,请参阅 windows - Why are changes to my PATH not being recognised? - Super User

pip 实际上是在警告您这种情况...

The script virtualenv-clone.exe is installed in 'C:\Users\andri\AppData\Roaming\Python\Python37\Scripts' which is not on PATH. Consider adding this directory to PATH... The script virtualenv.exe is installed in 'C:\Users\andri\AppData\Roaming\Python\Python37\Scripts' which is not on PATH. Consider adding this directory to PATH... The scripts pipenv-resolver.exe and pipenv.exe are installed in 'C:\Users\andri\AppData\Roaming\Python\Python37\Scripts' which is not on PATH. Consider adding this directory to PATH...

您需要添加该目录

C:\Users\andri\AppData\Roaming\Python\Python37\Scripts

到您的 PATH 环境变量;有很多方法可以做到这一点,例如参见Adding directory to PATH Environment Variable in Windows

另一种选择是始终使用

C:\...> C:\Users\andri\AppData\Roaming\Python\Python37\Scripts\pipenv install

但我认为这可能会很快变得有点陈旧。