pyenv找不到/使用pip(尽管找到了pip3)

时间:2019-03-29 14:26:10

标签: python pip virtualenv

尝试从virtualenv迁移到venv(python3)。还希望使用pyenv在我的Mac上管理多个版本的python 3.x。

在完成this之后,我通过pyenv安装了pyenv-virtualenvpyenv-virtualenvwrapperbrew,没有问题:

brew install pyenv
brew install pyenv-virtualenv
brew install pyenv-virtualenvwrapper

.zsh_env.sh中修改了我的~/.config/zsh_env.sh,如下所示:

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/workspace

eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

安装了两个Python版本:

➜  ~ pyenv versions
  system
  2.7.15
* 3.7.2 (set by /Users/ugur/.python-version)

尝试创建虚拟环境,但是我抱怨缺少pip

➜  ~ pyenv virtualenv 3.7.2 jupyter3
pyenv: pip: command not found

The `pip' command exists in these Python versions:
  2.7.15

如果我尝试在终端中运行pip,则会收到相同的错误:

➜  ~ pip
pyenv: pip: command not found

The `pip' command exists in these Python versions:
  2.7.15

pip3似乎已安装/见过:

➜  ~ pip3

Usage:
  pip3 <command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
... (omitted)

如何结合使用pyenvvenv来管理环境和python版本?

编辑

尝试通过pip安装pip3,但操作不成功:

➜  ~ pip3 install pip
Requirement already satisfied: pip in ./.pyenv/versions/3.7.2/lib/python3.7/site-packages (18.1)
You are using pip version 18.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
➜  ~ pip install --upgrade pip
pyenv: pip: command not found

The `pip' command exists in these Python versions:
  2.7.15

编辑2

甚至对别名pip都没有帮助:

➜  ~ alias pip=pip3
➜  ~ pyenv virtualenv 3.7.2 jupyter3
pyenv: pip: command not found

The `pip' command exists in these Python versions:
  2.7.15

1 个答案:

答案 0 :(得分:1)

您可以像这样创建一个similink

ln -s /usr/bin/pip3 /usr/bin/pip

现在呼叫pip实际上是pip3