Last active
December 8, 2021 23:03
-
-
Save pm-hwks/8dcc922297083afb79abb05b33b7a7bb to your computer and use it in GitHub Desktop.
[Virtualenv setup] Setup python virtualenv on macos #macos #python #virtualenv #setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Simple python virtual environment management | |
python3 -m venv segement_demo | |
source segement_demo/bin/activate | |
pip3 install requests | |
##### ------------ end --------- ##### | |
# Install virtualenv & virtualenv wrapper | |
pip3 install virtualenv | |
pip3 install virtualenvwrapper | |
## put this in the .zshrc file | |
## Virtualenv | |
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3 | |
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv | |
#export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages' | |
source /usr/local/bin/virtualenvwrapper.sh | |
## Virtualenvwrapper command reference | |
https://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html | |
# create virtualenv | |
mkvirtualenv <abc> | |
mkvirtualenv -v --python=python2.7 p27 | |
# list all virtualenv | |
lsvirtualenv | |
# show all virtual env's | |
showvirtualenv | |
# activate virtual env | |
workon | |
echo $VIRTUAL_ENV | |
# list packages in the current virtual env | |
lssitepackages | |
# remove all site packages | |
wipeenv | |
############## Manage multiple versions of python #################### | |
## Reference : https://www.freecodecamp.org/news/manage-multiple-python-versions-and-virtual-environments-venv-pyenv-pyvenv-a29fb00c296f/ | |
############## Install pyenv #################### | |
## Install pyenv to manage multiple versions of python | |
brew install pyenv | |
## Install pyenv on centos | |
curl https://pyenv.run | bash | |
## Add this to the .bashrc | |
export PATH="/home/centos/.pyenv/bin:$PATH" | |
eval "$(pyenv init -)" | |
eval "$(pyenv virtualenv-init -)" | |
## Install development pre-reqs | |
sudo yum install @development zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel findutils | |
############## pyenv commands #################### | |
## Activate pyenv | |
eval "$(pyenv init -)" | |
## Install requisite python version | |
pyenv install 3.8.1 | |
## Set the active python version | |
pyenv local 3.8.1 | |
## install pyenv virtualenv | |
brew install pyenv-virtualenv | |
## Activate pyenv - virtualenv | |
eval "$(pyenv virtualenv-init -)" | |
## Create a new pyenv - virtualenv | |
pyenv virtualenv 3.8.1 p381 | |
## activate specific environment | |
pyenv activate p381 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment