Forked from IamAdiSri/Python3, Pip3, Virtualenv and Virtualenvwrapper Setup
Created
September 15, 2017 04:02
-
-
Save jseadragon/a00a721c640525acf4a18b153523ce3f to your computer and use it in GitHub Desktop.
Setting up and using Python3, Pip3, Virtualenv (for Python3) and Virtualenvwrapper (for Python3)
This file contains 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
First install pip for Python2. Download the get-pip.py file from https://bootstrap.pypa.io/get-pip.py | |
$ cd <download location> | |
$ sudo -H ./get-pip.py | |
Use pip to install pip3 | |
$ sudo -H pip install pip3 | |
Installing pip3 also installs Python3 | |
To run Python3 | |
$ python3 | |
To install virtualenv via pip | |
$ sudo -H pip3 install virtualenv | |
{If you want to use virtualenv as is, read below, else skip to the next pair of braces} | |
Note that virtualenv installs to the python3 directory. For me it's: | |
$ /usr/local/share/python3/virtualenv | |
Create a virtualenvs directory to store all virtual environments | |
$ mkdir somewhere/virtualenvs | |
Make a new virtual environment with no packages | |
$ virtualenv somewhere/virtualenvs/<project-name> --no-site-packages | |
To use the virtual environment | |
$ cd somewhere/virtualenvs/<project-name>/bin | |
$ source activate | |
You are now using the virtual environment for <project-name>. To stop: | |
$ deactivate | |
{Continue installation} | |
To install virtualenvwrapper | |
$ sudo -H pip install virtualenvwrapper | |
Add the following lines to ~/.bashrc (or your own shell's initialisation file) | |
> VIRTUALENVWRAPPER_PYTHON='/usr/bin/python3' | |
> source /usr/local/bin/virtualenvwrapper.sh | |
> export WORKON_HOME=$HOME/.virtualenvs | |
Run the following commands | |
$ mkdir ~/.virtualenvs | |
$ source ~/.bashrc | |
All the virtual environments created using virtualenvwrapper will now be stored in ./virtualenvs | |
To create new virtual environment | |
$ mkvirtualenv <project name> | |
The virtualenv will automatically activate after creation | |
Install packages local to the virtualenv (and not global to the system) using | |
$ pip3 install <package-name> | |
To exit the virtualenv | |
$ deactivate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment