I often use python2.7! But suddenly I have to use python3 series! Isn't it possible to use python3 system without breaking the environment of python2.7? A note of virtualenv that is convenient at that time.
brew install pyenv-virtualenv
pip install virtualenvwrapper
if [ -f /usr/local/bin/virtualenvwrapper.sh ]; then
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
fi
pyenv install 3.3.6
pyenv versions
Now it looks like this:
MacBook-Pro:~ hoge$ pyenv versions
* system
3.3.6 (set by /Users/hoge/.pyenv/version)
python3.3.6 is stored in /Users/hoge/.pyenv/shims/python3.3.
mkvirtualenv --python=/Users/hoge/.pyenv/shims/python3.3 python3.3[Any name]
(python3.3)MacBook-Pro:~ hoge$ python -V
Python 3.3.6 # python3.3.6 available.
(python3.3)MacBook-Pro:~ hoge$ #previous()Indicates that is using the environment created by the above command.
(python3.3)MacBook-Pro:~ hoge$ which python
/Users/hoge/.virtualenvs/python3.3/bin/python #It is the path specified by mkvirtualenv.
(python3.3)yusuke-no-MacBook-Pro:~ hoge$ which pip
/Users/hoge/.virtualenvs/python3.3/bin/pip #The path of pip also changes.
deactivate #Deactivate
workon python3.3 #Activate
With this, for example, if you install PILLOW with pip in the python3.3 environment, you can use it in the 3.3 environment, but if you deactivate it, you can not use PILLOW.
Recommended Posts