1

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?

0

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

3 Comments

Thank You. For some reason when I do $ mkvirtualenv venv27 in the command prompt I get the message '$' is not recognized as an internal or external command.
I have aded the $ sign as just an formatting indication, that it should be ran in the terminal. So you should actually run mkvirtualenv venv27.
I suppose you are using Windows, so maybe this will also help you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.