One of the first bits of advice I was given was to use virtualenv which allows you to isolate python environments, rather than just using the machines environment (and cluttering it/get clashes of versions etc)
The project I'm working on uses Django with a Postgres database, so here are the steps I needed to get it working. I'm using the default version of python however you can install different ones.
#install virtualenv
sudo apt-get install python-virtualenv
#install headers needed for psycopg2
#You can skip the next line if you're not using postgres as the databasesudo apt-get install libpq-dev python-dev#create a folder for the virtual environmentmkdir mypyenv#create the virtual environment#no-site-packages ensures the environment doesn't also include packages installed at machine levelvirtualenv --no-site-packages --distribute mypyenv#switch to environment (environment name will be in brackets on terminal)source mypyenv/bin/activate#install djangopip install -E mypyenv Django
#I'm using piston also for my api - skip if you don't want itpip install -E mypyenv django-piston
#install djangopip install -E mypyenv psycopg2
That should now be installed. Now just switch to your project folder and you should be able to work with it. If this is your first project then I'd highly recommend the official tutorial
Once you're finished using virtual environment, use the deactivate command to come out of it.
No comments:
Post a Comment