尝试从virtualenv
迁移到venv
(python3)。还希望使用pyenv
在我的Mac上管理多个版本的python 3.x。
在完成this之后,我通过pyenv
安装了pyenv-virtualenv
,pyenv-virtualenvwrapper
和brew
,没有问题:
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)
如何结合使用pyenv
和venv
来管理环境和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
甚至对别名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
答案 0 :(得分:1)
您可以像这样创建一个similink
ln -s /usr/bin/pip3 /usr/bin/pip
现在呼叫pip
实际上是pip3
。