I would strongly suggest avoiding
pip3 to install things in the system site-packages. I've made these arguments before but I'll give you the notes:
- System updates break everything
- Installing apt packages can overwrite pip-installed things
- Version conflicts
- Distribution upgrades are unpredictable chaos. Seriously. I've lost hair to these.
I would strongly advocate using
virtualenv. It's a massive pain in the wherever to get going but once you've got it set up you have a complete Python environment under your complete control. This does mean more work (you'll have to check things for updates and
pip doesn't really help there yet) but you don't have to worry about what Ubuntu's doing.
I personally opt for one virtualenv for all my sites. Many people suggest one environment per site. There is sense in both routes.
In terms of installing this, and just to slap me in the face,
virtualenv isn't packaged for Python 3 yet so we have to use
$ sudo pip3 install virtualenv
$ virtualenv-3.3 myenv
Using base prefix '/usr'
New python executable in myenv/bin/python3
Also creating executable in myenv/bin/python
Installing setuptools, pip...done.
$ source myenv/bin/activate # This is important!
Your bash PS1 should now be preneded with
(myenv) to let you know you're in a different environment. We can test the environment to check we're on the right versions of things (not using the system versions for starters):
$ python --version
$ which python pip
And then you can just carry on as if you were master of the universe. You don't need root to use
pip anymore and you don't need to specify
pip3. It's just a lot more friendly.
$ pip install django umemcache
If you're using something like
uwsgi to host this (you should) use its -H flag (or home config argument) to tell it where the Python environment lives.
As for making development easier, you can automatically "mount" your
virtualenv environment. There are many scripts out there but this one is mine (this lives at the bottom of my
[[ $wd == $VENVDIR/* || $wd == $VENVDIR ]] && wasin=true || unset wasin
builtin cd "$@"
if [[ $wd == $VENVDIR/* || $wd == $VENVDIR ]]; then
[ $wasin ] && deactivate
/web (where all my development websites are stored), it mounts the virtualenv for me. Note that I only have one environment for all my sites so this will only suite you if you do something similar. There are many other ways of doing similar things.