Tuesday, May 1, 2012
django integration in pydev with virtualenv
[UPDATE 2013-01-16] This is no longer an issue. PyDev will use the Django version (and django-admin.py) that you have in your Python interpreter and that you selected during set up of the "New Project."
Django integration in the PyDev Eclipse plugin is pretty cool. You can run most of the Django commands, like "django-admin startproject", "syncdb" and even start a Django shell all from Eclipse. But it can be a tiny itsy-bit tricky if you are using virtualenv or virtualenvwrapper. The trick is to use --no-site-packages option, which is default on virtualenv 1.7.2. The reason is that if you include site or global packages, and you have different version of Django installed in your virtualenv and your global Python installation, then you will have two /bin/django-admin.py scripts, and so most likely, PyDev will run the global script, which is probably not what you want. Another trick is to select all when setting up your virtualenv Python interpreter in PyDev. The last trick is to use virtualenvwrapper, and/or keep all of your virtualenvs in a single location. If you are on Windows, make this path is close to the "root" of your C-drive and without any spaces. This will save you heartache as spaces don't expand well in shell scripts. For example, use C:\.virtualenvs. The dot is optional, but it's the recommendation by virtualenvwrapper. If you are on Linux, the default, ~/.virtualenvs is probably fine.s
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment