You may be confused at first the differences between,
Especially, virtualenv
sounds like Linux virtual environment, but it isn’t at all.
Here is the good answer about that.
Conclusion: pyenv-virtualenv
is the best choice.
pyenv-virtualenv
official: https://github.com/pyenv/pyenv-virtualenv
Install pyenv in macOS (or other Linux environments).
# Download source under ~/.pyenv
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
# Set PATH and another variable
echo -e '\n
export PYENV_ROOT=$HOME/.pyenv
export PATH=$PYENV_ROOT/bin:$PATH
eval "$(pyenv init -)"
' \
>> ~/.zshrc
In the case of WSL, .bashrc
instead .zshrc
.
git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.zshrc
source ~/.zshrc
In case of WSL and PoP!OS 20.10, install the followings.
sudo apt install make zlib1g zlib1g-dev bzip2 libbz2-dev libreadline8 libreadline-dev libssl-dev libsqlite3-dev tk-dev liblzma-dev
pyenv install --list
Following command install Python 3.8.1 environment.
pyenv install 3.8.1
pyenv rehash
This environment would be the base of your own Python environment.
I made an environment which name is nlp
and its Python version is 3.8.1.
pyenv virtualenv 3.8.1 nlp
pyenv rehash
pyenv versions
* system (set by /Users/atlex/.pyenv/version)
3.8.1
3.8.1/envs/nlp
In this sample, there are 3 environment, and I’m using system
environment.
Now I activate the environment I maed.
pyenv activate nlp
And feel free to use your Python environment!
After you’ve done your work, log out from your environment if you need.
pyenv deactivate
If you have failed to build your environment, following command delete your environment.
pyenv uninstall nlp
https://stackoverflow.com/questions/43993714/why-is-python-3-6-1-not-available-in-pyenv
cd $(pyenv root) && git pull