Reputation: 1117
This may have been asked before but I wasn't able to find any information on it. If I am running multiple versions of Python, namely Python 2.7
and Python 3.3.5
, how do I install libraries for a particular version among the two?
Upvotes: 1
Views: 116
Reputation: 7458
You would rather consider using Virtual Environments for Python. It will let you create separate and independent Python environments, for different version of Python, as well as packages.
I would also recommend this package, which just wraps virutalenv
and adds handy functionality.
So concretely for your situation, you may create two environments for Python 2.7
and 3.3.5
, and install the required libraries for each virtualenv
. Here is a brief example of what you will have to do:
$ mkvirtualenv venv27 # This will create and activate virtualenv for Python 2.7
$ deactivate # ...to deactivate venv27
$ mkvirtualenv venv33 -p /usr/bin/python3.3 # same for Python 3.3.5
$ deactivate
Note the -p
option, which specifies the Python interpreter for that virtual environment.
After creating your virtual environment, you can start working on them using the workon
utility:
$ workon venv27 # or venv33
Upvotes: 3