1👍
You need to use a virtual environment, and install the dependencies for your project in each virtual environment.
This way, the Python interpreter will have access to the required libraries at all times. To get started:
sudo apt-get install -y python-virtualenv
This will install any required libraries to make virtualenv
work; then for each project you start by creating a fresh virtual environment. All these commands are run as your normal user (without sudo
):
$ virtualenv django_env
$ source django_env/bin/activate
(django_env) $ pip install django tastypie solr-thumbnail
Typing activate
will activate the enviornment, so your shell will point to the correct versions of Python. You’ll note the (django_env)
which indicates the environment is currently active.
From this point on, anything you install will be installed only in this virtual environment. Once you are finished working, typing deactivate
will return you back to the system Python environment:
(django_env) $ deactivate
$