When I set macOS to Sierra, Python's virtualenv doesn't work well, so I decided to rebuild the virtual environment with pyenv. The procedure at that time is summarized. It's easy, so you only need to remember the basic commands! It's easy to install, so even elementary school students can do it without any problems! !!
$ brew install pyenv
There are many versions coming out, so please install the version you like
$ pyenv install -l
Available versions:
2.1.3
2.2.3
2.3.7
2.4
2.4.1
2.4.2
2.4.3
2.4.4
2.4.5
2.4.6
2.5
2.5.1
2.5.2
...
When installing Python 3.5.2.
$ pyenv install 3.5.2
$ brew install pyenv-virtualenv
If you want the whole python version to be 3.5.2.
$ pyenv global 3.5.2
When reflecting only a specific directory
If you type the command pyenv local XXX
in a specific directory, the python version will be applied only to that directory.
$ cd PROJECT_DIR
$ pyenv local 2.7.10
Since it is difficult to change the environment with pyenv, I think it is basically more convenient to build a virtual environment with pyenv-virtualenv.
When creating a virtual environment with Python 3.5.2.
$ pyenv virtualenv 3.5.2 test
$ pyenv activate XXXXX
$ pyenv deactivate
For NAME, enter the name of the virtual environment you created.
$ pyenv uninstall NAME
pyenv-virtualenv: remove /Users/xxxx/.pyenv/versions/3.5.2/envs/test2? [Enter y]
Recommended Posts