Python 3 Virtualenv/Virtualenvwrapper macOS Quick Start
The Unix Tutorial shows you Step-by-Step How to Install and Getting-Started with Python 3.x/2.x Virtualenv and Virtualenvwrapper for macOS 10.10 Yosemite Unix/BSD.
A Virtualenv Environment, put simply, is an isolated working copy of Python which allows you to work on a specific project without worry of affecting other projects.
The Virtualenvwrapper include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies.
-
Open a Command Line Terminal Window
Applications > Utilities > Terminal
(Press “Enter” to Execute Commands)In case first see: Terminal QuickStart Guide.
-
Getting-Started with Python 3 on macOS Yosemite
-
Installing Virtualenv+Virtualenvwrapper Python 3.
sudo pip3 install virtualenvwrapper
-
Initial Virtualenv SetUp.
nano $HOME/.profile
Append:
export WORKON_HOME=~/Envs/nexport VIRTUALENVWRAPPER_PYTHON=/usr/local/homebrew/bin/python3
Ctrl+x to Save & Exit from ‘nano’ Editor :)
source $HOME/.profile
source /usr/local/homebrew/bin/virtualenvwrapper.sh
Then you Dispose of 2 Virtualenv Versions: ‘virtualenv’ for Python 3.x and ‘virtualenv-2.x’ for Python 2.x :)
To Show Up:ls -l /usr/local/homebrew/bin | grep virtualenv
-
To Make a Python Virtual Environmnet.
mkvirtualenv test
-
To List All the Existing Virtual Environments.
ls $WORKON_HOME
-
To Switch the Virtual Environmnet.
mkvirtualenv essai
workon test
Show the Working Virtual Env:
echo $VIRTUAL_ENV
-
To Install Software into the Virtual Environmnet.
For Example:
pip3 install django
-
To List All the Virtual Environmnet Packages.
lssitepackages
-
To Automatically Run a Command after Environment Creation.
echo '[sh-command]' > $WORKON_HOME/postactivate
For Instance to Automatically Change to the New Env Directory:
echo 'cd $VIRTUAL_ENV' > $WORKON_HOME/postactivate
-
To Automatically Installing Commonly Used Tools.
echo 'pip3 install [myGoodTool]' > $WORKON_HOME/postmkvirtualenv
For Example:
echo 'pip3 install sphinx' > $WORKON_HOME/postmkvirtualenv