最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】pipenv安装后警告:The script virtualenv is installed in which is not on PATH

Python crifan 16099浏览 0评论

折腾:

【已解决】Mac本地用pipenv搭建Flask开发环境

期间,以用户模式安装pipenv:

<code>  robotDemo pip3 install pipenv --user
Collecting pipenv
  Downloading https://files.pythonhosted.org/packages/e5/fd/740a41c68c38262265d73191fb686f38d26c4ea1ea6080a65b2b626bedc7/pipenv-11.10.0-py3-none-any.whl (5.6MB)
    100% |████████████████████████████████| 5.6MB 3.3MB/s
Requirement already satisfied: setuptools&gt;=36.2.1 in /usr/local/lib/python3.6/site-packages (from pipenv) (38.5.2)
Collecting virtualenv (from pipenv)
  Downloading https://files.pythonhosted.org/packages/ed/ea/e20b5cbebf45d3096e8138ab74eda139595d827677f38e9dd543e6015bdf/virtualenv-15.2.0-py2.py3-none-any.whl (2.6MB)
    100% |████████████████████████████████| 2.6MB 8.6MB/s
Collecting certifi (from pipenv)
  Downloading https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl (150kB)
    100% |████████████████████████████████| 153kB 8.1MB/s
Collecting virtualenv-clone&gt;=0.2.5 (from pipenv)
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/6d/c2/dccb5ccf599e0c5d1eea6acbd058af7a71384f9740179db67a9182a24798/virtualenv_clone-0.3.0-py2.py3-none-any.whl
Requirement already satisfied: pip&gt;=9.0.1 in /usr/local/lib/python3.6/site-packages (from pipenv) (10.0.0)
Installing collected packages: virtualenv, certifi, virtualenv-clone, pipenv
  The script virtualenv is installed in '/Users/crifan/Library/Python/3.6/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/crifan/Library/Python/3.6/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 pewtwo, pipenv and pipenv-resolver are installed in '/Users/crifan/Library/Python/3.6/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.
Successfully installed certifi-2018.4.16 pipenv-11.10.0 virtualenv-15.2.0 virtualenv-clone-0.3.0
</code>

很明显看到提示了:

感觉需要去把这里提示的:

<code>/Users/crifan/Library/Python/3.6/bin
</code>

加到PATH中?

先去看看里面有啥:

<code>➜  robotDemo ll /Users/crifan/Library/Python/3.6/bin
total 40
-rwxr-xr-x  1 crifan  staff   242B  4 17 11:06 pewtwo
-rwxr-xr-x  1 crifan  staff   226B  4 17 11:06 pipenv
-rwxr-xr-x  1 crifan  staff   237B  4 17 11:06 pipenv-resolver
-rwxr-xr-x  1 crifan  staff   232B  4 17 11:06 virtualenv
-rwxr-xr-x  1 crifan  staff   237B  4 17 11:06 virtualenv-clone
</code>

此刻去找一下,果然找不到:

<code>➜  robotDemo which pipenv
pipenv not found
</code>

pipenv The script virtualenv is installed in  /Library/Python/3.6/bin which is not on PATH

python – pipenv install gives “pew is not in your PATH” – Stack Overflow

pew which is in $PATH is not found · Issue #913 · pypa/pipenv

看看现在此刻的PATH:

<code>➜  robotDemo echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
</code>

看到了,之前就看到过的文档:

Pipenv & Virtual Environments — pipenv 11.10.0 documentation

http://pythonguidecn.readthedocs.io/zh/latest/dev/virtualenvs.html

“注解

这进行了 用户安装,以防止破坏任何系统范围的包。如果安装后, shell 中没有pipenv,则需要将 用户基础目录 的 二进制文件目录添加到 PATH 中。”

所以很明显就是:

此处用 用户模式 安装了pipenv,安装后,对应的目录没有加到PATH中,所以人家最后提示你加入该路径到PATH中,否则shell中找不到pipenv(和其他相关的pewtwo,pipenv-resolver,virtualenv,virtualenv-clone)

去看看:

<code>➜  robotDemo which pewtwo
pewtwo not found
➜  robotDemo which pew
pew not found
➜  robotDemo which virtualenv
/usr/local/bin/virtualenv
➜  robotDemo ll /usr/local/bin/virtualenv
-rwxr-xr-x  1 crifan  admin   232B  1 27 13:14 /usr/local/bin/virtualenv
➜  robotDemo virtualenv --version
zsh: /usr/local/bin/virtualenv: bad interpreter: /usr/local/opt/python/bin/python2.7: no such file or directory
➜  robotDemo virtualenv --help
zsh: /usr/local/bin/virtualenv: bad interpreter: /usr/local/opt/python/bin/python2.7: no such file or directory
➜  robotDemo which virtualenv-clone
virtualenv-clone not found
</code>

发现,除了之前已经安装过的virtualenv,其他的确是找不到

而新装的virtualenv是15.2.0:

<code>➜  robotDemo ll /Users/crifan/Library/Python/3.6/bin/virtualenv
-rwxr-xr-x  1 crifan  staff   232B  4 17 11:06 /Users/crifan/Library/Python/3.6/bin/virtualenv
➜  robotDemo /Users/crifan/Library/Python/3.6/bin/virtualenv --version
15.2.0
</code>

所以就去添加路径到path中:

而为了每次启动后都生效,则去参考:

https://github.com/pypa/pipenv

“Alternatively, with bash, put this in your .bashrc or .bash_profile:”

添加到.bashrc中去:

另外,待会记得参考:

利用pipenv和pyenv管理多个相互独立的Python虚拟开发环境 – CSDN博客

把:

<code>export PIPENV_VENV_IN_PROJECT=1
</code>

也记到PATH中去。

而具体的export PATH的修改办法,参考:

https://github.com/pyenv/pyenv/blob/master/README.md

去加上:

<code>export PATH="/Users/crifan/Library/Python/3.6/bin:$PATH"
</code>

<code>➜  robotDemo cat ~/.bashrc

export NVM_DIR="/Users/crifan/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] &amp;&amp; . "$NVM_DIR/nvm.sh"  # This loads nvm

export PATH="/Users/crifan/Library/Python/3.6/bin:$PATH"
</code>

而为了此刻生效,还要source一下:

<code>➜  robotDemo source ~/.bashrc
</code>

然后再去看看PATH,路径就加上去了:

<code>➜  robotDemo echo $PATH
/Users/crifan/Library/Python/3.6/bin:/Users/crifan/.nvm/versions/node/v5.4.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
</code>

【总结】

此处,pipenv安装后,默认没有把对应的pipenv(以其他相关的pewtwo,pipenv-resolver,virtualenv,virtualenv-clone)的所在路径,此处是:

/Users/crifan/Library/Python/3.6/bin

加入到PATH中,这会导致命令行中找不到pipenv(和另外几个)

解决办法是:

按照提示的,把上述路径加到PATH中。

做法:

1.把:

<code>export PATH="/Users/crifan/Library/Python/3.6/bin:$PATH"
</code>

加到.bashrc中 -》为了以后每次启动电脑后,PATH中都包含该路径。

2.再去:

<code>source ~/.bashrc
</code>

是为了当前此刻,PATH中包含该路径。

这样命令行中就可以找到这些pipenv等工具了。

转载请注明:在路上 » 【已解决】pipenv安装后警告:The script virtualenv is installed in which is not on PATH

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.358 seconds, using 22.21MB memory