It is strongly recommended that you install python packages in a virtualenv. Here are some brief steps to install virtualenv on linux:
Install pip
$ sudo apt-get install python-pipInstall virtualenv
$ sudo pip install virtualenvI store my virtualenvs in a dir ~/venvs
$ mkdir ~/venvsAt this point you are all set to use virtualenv with the standard commands. However, I prefer to use the extra commands included in virtualenvwrapper. Lets set that up.
Install virtualenvwrapper
$ sudo pip install virtualenvwrapperSet WORKON_HOME to your virtualenv dir
$ export WORKON_HOME=~/venvsAdd virtualenvwrapper.sh to .bashrc.
Add this line to the end of ~/.bashrc so that the virtualenvwrapper commands are loaded.
$ source /usr/local/bin/virtualenvwrapper.shExit and re-open your shell, or reload .bashrc with the command source ~/.bashrc and you’re ready to go.
Create a new virtualenv
$ mkvirtualenv myenvTo create a python3 virtualenv use the following:
$ mkvirtualenv -p python3 myenvThis will create a python3 virtualenv using your system installed python3 version. If you want to install another python3 interpreter, follow this approach.
To exit your new virtualenv, use deactivate:
$ deactivateTo load or switch between virtualenv, use the workon command:
$ workon myenv
If
matplotlibdoes not play well in avirtualenv, use this:sudo apt-get -y build-dep matplotlibThen install
matplotlibagain in yourvirtualenv.