AngusTheMan
AngusTheMan

Reputation: 582

How to use a virtual environment

Using Python I require both python 2.7 and python 3.5 for different packages. I am trying to install the following package NepidemiX. I get an error when I do this as I have a newer version of python installed.

To combat this I am trying to create a virtual environment. To do this I am using the virtualenv package.

I have created and activated this and am now faced with

(my_project)Your-Computer:your_project UserName$) 

In my terminal.

How do I now proceed to install my package from here? Do I need to install python 2.7 in this environment first, or do I simply copy the desired package into the environment ... ?

Please could you instruct me how to correctly set this up? Many thanks!

Upvotes: 2

Views: 257

Answers (1)

Alex
Alex

Reputation: 1262

Virtual environment is only for libraries. It uses python versions installed on your computer. You can specify the version of python by using the -p attribute while creating the environment, for ex. virtualenv -p python3 env creates a python 3 enviroment (provided you have it installed in your computer and on the PATH). Check this answer. After you activate the environment (source /env/bin/activate), just pip install libraries, and the environment takes care of installing the correct version.

Upvotes: 2

Related Questions