As noted in the Ubuntu wiki page on Rails it is recommended that gems manages your Rails/Ruby dependencies.
What is the best practise with Python packages like Django? Should I install them through apt-get or should I let easy_install/pip fetch them from PyPi?
There are several arguments:
Use Repositories/PPAs because they will keep you both stable and up to date with security fixes.
This is mostly true. If, for example, you install
python-djangoas I have, you get security updates. This is good because you only have to keep on top of apt but you still have to test things before you push updates (although testing should be fine each time).
You could argue that if you used
pip, you might never check for updates.
pipso you can use the proper "stable" versions.
There's no doubt about it: The repos lag behind the real world. Django is 2.0 but the repos for the LTS version of Ubuntu (that a lot of people stick with for servers) you only get 1.8 on Ubuntu 16.4 lts with Python 2 but still get security updates on it.
pipgives you the latest all the time. You just have to update them yourself.
Upgrading a repo-used Python install can be a nightmare
When you dist-upgrade Ubuntu to the next version, it upgrades a lot of packages. Lots of things change. I know in Django this means you have to take care to watch out for code-incompatibilities, deprecations... But the same applies to all other Python code.
The same is true for
pipyou get to do one thing at a time. You know what causes the problems so you know where to look to find the fix.
virtualenvlets you keep things separate
virtualenvlets you have portable, little Python environments. This allows you to have several different Python environments running alongside each other on the same machine.
The obvious boon seems to be for maintenance as you can manage the environment in the same way as you manage the code. Even store the environment in the VCS too... but you should remember that having twelve different
virtualenvs means twelve environments you need to check on and update.
Edit: After a horrible series of upgrades on a server to get it from Lucid to Precise, I've switched from a mixed Apt+pip (nr 1 and 2) to a pure pip+virtualenv (nr. 4) situation. Instead of having one virtualenv per site, I've got one shared one between a dozen-or-so sites. This is working for now.
I've also had to write a little script that checks the status of packages installed with pip. If there are updates I have to apply them manually (which is good because I test them locally, in a local virtualenv). This is all still a little more painful than it was originally but much better in the long run.