1

I'm starting to use python and would like to setup my workstation which is running on linux (debian). Multiple version of python are installed:

ot@station:/home/ot# ls -l /usr/bin/py
py3clean           pydoc3.4           python2            python3.4m-config
py3compile         pygettext          python2.6          python3-config
py3versions        pygettext2.7       python2.7          python3m
pybuild            pygettext3         python2.7-config   python3m-config
pyclean            pygettext3.4       python2-config     python-config
pycompile          pygmentex          python3            pythontex
pydoc              pygmentize         python3.4          pythontex3
pydoc2.7           pyste              python3.4-config   pyversions
pydoc3             python             python3.4m         
root@thinkstation:/home/nicolas# ls -l /usr/bin/py

My first question is regarding the package management system pip. I see the following output:

ot@station:/home/ot# pip
pip     pip2    pip2.7  

How can I check which pip is used for which python version? They must be linked somehow. From the output above I guess pip2.7 is used for the installed version of python2.7. But what about the others? Why isnt there a pip2.6 and how can I use pip to install packages for the newest version (python 3.4?).

Once this is sorted out I would like to start some coding projects for which virtualenv seems extremely helpful. At this point I know which pip links to which python version. If my project should run under python3 I use the corresponding pip to install virtualenv and virtualenvwrapper. This implies there are different version of virtualenv and virtualenvwrapper on my local machine. How can I then use the right one for creating local environment?

math
  • 1,868
  • 4
  • 26
  • 60

1 Answers1

1
sudo apt-get install python3-pip  # install pip3
pip3 install virtualenv  

virtualenv venv  # create virtualenv called venv
source /venv/bin/activate  # activate the virtualenv
pip install xyz
[...]
deactivate

Note: to install packages within the virtual environment you simply use pip, even if its an python3 environment.

For further info on pip versions check out this post.

Community
  • 1
  • 1
imant
  • 597
  • 5
  • 15