Dropbox and Python Virtualenv

Since most of my systems are 64 bits macs, and I was using Python's excellent virtualenv system, I though it was possibly to just copy over the virtualenvs inside my project folders.

Fact is that after a while, Dropbox will get stuck in changing some system's file permission, and it wont' sync anymore. As I found out, the only solution is to move your virtual envs out of the Dropbox folder. I hope to save you some time with this tip.

If you don't know it, Virtualenv basically links your system's python library and interpreter in a folder you specify, letting you use pip to install locally any module you need without polluting the system's paths.

But Dropbox doesn't like those symlinks, especially when they link system folders.

Quick fix: If you use virtualenv you should create your envs in a folder not synched by dropbox, i.e. something like ~/.virtualenvs/ i.e.

virtualenv ~/.virtualenvs/myproject

When you are done installing all the modules using pip you can generate a requirements.txt file using

pip freeze > requirements.txt

Then when you are on another machine re-create the virtualenv using the first command and reinstall every module using pip install -r requirements.txt. Remember to activate your newly created virtualenv first.

Comments !