My Mac broke and I was building a Python environment from the beginning There is no virtualenv in pyenv! !! I was scolded by terminal Added to install pyenv-virtualenv when pyenv install. Since virtualenv cannot be deleted, it is modified to pyenv uninstall virtualenv_name.
I'm using pyenv-virtualenv in Anaconda's environment When I check with python -V, the Python version is fixed Is (virtualenv_name) displayed all the time on the terminal line and you can't deactivate it? Yes, I am.
So, I finally got to change the Python environment by referring to the articles of Qiita gentlemen and ladies. This is an article compiled for MEMO.
Articles that I used as a reference Markdown notation cheat sheet Note from installing Homebrew to building an Anaconda environment for Python with pyenv Building a python environment for each directory with pyenv-virtualenv virtualenv basic command usage memo Building an environment with pyenv and virtualenv Python environment construction for those who aim to become data scientists 2016 Install the Python environment with Anaconda [Definitive Edition] Building an environment for learning "machine learning" using Python on Mac
First, install pyenv with Brew. Open terminal
pyenv and pyenv-Install virtualenv
$brew install pyenv
$brew install pyenv-virtualenv
If you don't have Brew, install Brew first. Please refer to the many articles that were taken care of by Qiita.
Once pyenv is installed, play with .bash_profile. Open Terminal
.bash_Describe the following in profile
$echo 'export PYENV_ROOT="${HOME}/.pyenv"' >> ~/.bash_profile
$echo 'export PATH="${PYENV_ROOT}/bin:$PATH"' >> ~/.bash_profile
$echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
Don't forget the "{}", as python --version will look weird later even though Anaconda is set up in pyenv.
with cat.bash_Check the contents of profile
$cat ~/.bash_profile
After rewriting .bash_profile, close and reopen terminal, source ~ / .bash_profile.
Now, let's install Python with pyenv. First, display a list of Python versions that can be installed with pyenv.
Python_version_list display
$pyenv install -l
Install any of the listed Python versions. Of course, looking at this article is Anaconda, isn't it? Please install and verify both 2nd and 3rd series.
Install Anaconda with pyenv
$pyenv install [python_version]
$pyenv install [another_python_version]
Check the version of python installed in pyenv.
Python installed in pyenv_version confirmation
$pyenv versions
It's OK if multiple python_versions set in system are displayed, Also, the activated python_version is prefixed with *.
Here is a review, but in pyenv global (reflected in any directory) You can set python_version of local (only the current directory at the time of setting is reflected).
global python_version setting
$pyenv global [python_version]
Let's see if the global python_version is set successfully.
python set to global_version confirmation
$pyenv global
Did you see the python_version you set earlier?
Next, try setting the local python_version.
local python_version setting
$pyenv local [python_version]
Check if local python_version is set in the current directory.
python set to local_version confirmation
$pyenv local
I think you can see the python_version set to local Remove the python_version set to local once.
local set python_Release version
$pyenv local --unset
Update the python version displayed in the pyenv install list
$brew update
$brew upgrade pyenv
virtualenv Now let's get into the virtualenv settings. You can build and use a virtual environment with your favorite python_version.
Virtual environment python_Set version and name
$pyenv virtualenv [python_version] [virtualenv_name]
Let's check if the virtual environment virtualenv_name has been added to pyenv.
virtualenv in pyenv_Check if name has been added
$pyenv versions
After confirming that it has been added, let's activate the virtual environment virtualenv_name.
Virtual environment virtualenv_activate name
$pyenv activate [virtualenv_name]
Did you see (virtualenv_name) at the beginning of the terminal line? You can activate it in any directory.
Now, let's cancel the virtual environment virtualenv_name.
Virtual environment virtualenv_deactivate name
$pyenv deactivate
Did the (virtualenv_name) displayed at the beginning of the terminal line disappear?
Delete the virtual environment virtualenv_name that was built last.
Virtual environment virtualenv_delete name
$pyenv uninstall [virtualenv_name]
MEMO is over !!
After setting the virtualenv of anaconda3-4.0.0 to local yesterday When I python -V, 3.6.0 is displayed, it should be 3.5.1 ... I'm a super beginner enough to use Markdown notation for the first time With the accumulation of Qiita's Knowledge, it is now possible to play with python somewhat decently. We would like to express our utmost gratitude to everyone who shared many good articles and Qiita.
Recommended Posts