我设置了一个虚拟环境来下载pipenv软件包。如何将结果目录添加到PATH?

时间:2018-10-28 22:52:52

标签: python terminal pipenv

我在MacBook Air(Mojave 10.14)中安装了Python 3.7。首先,我得到了“命令行工具”,然后是Homebrew,最后是python 3.7。我按照在https://docs.python-guide.org/starting/install3/osx/#install3-osx

上找到的说明进行操作

当我想安装Pipenv时,问题开始了。在终端上的第一次尝试中,我收到一条消息:“由于EnvironmentError无法安装软件包:[Errno 13]权限被拒绝”。阅读后,我发现最好的解决方案是创建一个虚拟环境来下载pipenv。所以我写了命令:

python3 -m venv env
source ./env/bin/activate 
python -m pip install -- user pipenv

它起作用了,但似乎我需要将此目录添加到PATH。我在Terminal上收到了以下答案。

The script virtualenv is installed in '/Users/marianasierra/Library/Python/3.7/bin' 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-clone is installed in '/Users/marianasierra/Library/Python/3.7/bin' 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 and pipenv-resolver are installed in '/Users/marianasierra/Library/Python/3.7/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

我试图将目录添加到PATH,但由于我仍然在Terminal上看到(env),因此我认为该目录不起作用。在这种情况下我该怎么办?该especific目录应如何添加到PATH?

我最后的命令是:

(env) Marianas-MacBook-Air:~ marianasierra$  python -m site --user-base /Users/marianasierra/Library/Python/3.7
(env) Marianas-MacBook-Air:~ marianasierra$ export PATH="$PATH:/Users/marianasierra/Library/Python/3.7/bin"

1 个答案:

答案 0 :(得分:0)

但是为什么要这样做呢?那你可能会遇到问题

export PATH=$(which pipenv):$PTTH