Search code examples
pythondjangopippython-venv

how to get venv to point to older python version


I am trying to clone and run a project on my mac.

but on the installation options I have to run:

pip install -r requirements.txt

I get an error and I am pretty sure its because the project runs on python 2.7 while my venv runs on 3.4

(venv)/*
$ python --version
Python 3.4.3

however when I am outside of venv I run am back onto the correct python version:

$ python --version
Python 2.7.6

WHy is venv running 3.4? How can I change venv to not run 3.4 and just run the 2.7

Do I have to update an environment or venv variable on my system? I can't find where python is in my system. Also any advice on what commands to run would be appreciated as I am a bit new to python/django.

perhaps the pip I have in venv is wrong, idk. Any help is appreciated.


Solution

  • You can use the option -p to specify, which version should be used, when you create the virtual environment.

    For example:

    virtualenv -p python2.7 venv