[Django]-Is there a way to install django with pip to point to a specific version of python in virtualenv

5👍

Invoke django-admin.py like this python django-admin.py, in your activate virtualenv. Alternatively you can do /path/to/virtualenv/bin/python django-admin.py.
The best solution is probably adding a shebang to django-admin.py that looks like #!/usr/bin/env python which should use the python interpreter of your active virtualenv. See https://stackoverflow.com/a/2255961/639054

1👍

You could use pyenv, which will allow you to set your Python interpreter based on what directory you’re in. I also use it with pyenv-virtualenv so that I get all the benefits of isolating my packages per application.

There’s a bit of a learning curve, but it’s worth it if you need to switch Python interpreters to match a production server for instance.

Leave a comment