9👍
You want to do:
virtualenv --python=/path/to/python/version --no-site-packages ENV_NAME
For example:
virtualenv --python=/usr/bin/python2.6 --no-site-packages my_project_env
If you follow this for your projects you should be able to have a separate configuration for each one.
5👍
I have installed every Python verison I need (which is 2.4, 2.5, 2.6, 2.7, 3.1 and also 3.2) from source. That’s always the best thing to do, so you don’t mess up the system Python.
I installed them in /opt. Like so (you need a bunch of Ubuntu packages too, first):
./configure --prefix /opt/pythonxx
make -j2; make install # j2 is a nice trick there for dualcores not everyone knows.
Then I for each version install the things I need. I start with installing Distribute:
wget http://nightly.ziade.org/distribute_setup.py
/opt/pythonxx/bin/python distribute_setup.py
(Except for Python 3, who needs distribute_setup3.py)
Then I can install pip
/opt/pythonxx/bin/easy_install pip
And virtualenv:
/opt/pythonxx/bin/pip install virtualenv
(Virtualenv3 or virtualenv5 for Python 3)
And that’s it! If I want to make a virtualenv using Python 2.4, I do:
/opt/python24/bin/virtualenv foobar
And Python 2.7:
/opt/python27/bin/virtualenv foobar
Running python is just
/opt/python24/bin/python
Etc. I never install anything in the above Pythons except these modules, and PIL (because PIL is a pain, but now there is Pillow, so you don’t have to do that either). I use zc.buildout and virtualenv to keep the pythons clean.
- How to create a filter form for a (class based) generic object list in Django?
- How to send django objects to celery tasks?
- Django – Access fields on a model's "through" table from an instance
1👍
You can use virtualenv --no-site-packages ENVNAME
and that will make sure the default Django in your system Python won’t be included in your new environment.
For different versions of Python, you can follow these instructions from a superuser.com post.
- Ignore a specific test using Django
- How do I use request.META.get('HTTP_REFERER') within template?
- ImportError: No module named bootstrap3
- I cannot ignore pycache and db.sqlite on Django even though it refers them at .gitignore