English: Python logo Deutsch: Python Logo (Photo credit: Wikipedia) |
example of Python language (Photo credit: Wikipedia) |
First things first, let's install python, a nice editor, and pip (a tool to install python packages easily):
sudo apt-get install python geany python-pip
Then, we need virtualenv to create a virtual environment where our python configuration can differ from the one used in other directories. This is pretty useful to manage dependencies cleanly.
I recommend this good tutorial about virtualenv.
sudo pip install virtualenv mkdir virtualenv_1
virtualenv_1 will be our virtual environment.
virtualenv virtualenv_1 cd virtualenv_1
we activate this environment when we want to use it for a programming project for instance or to modify it (e.g., add python packages)
source ./bin/activate
The prompt changes to show that we are in our virtual environment. Let's install yolk to list the python packages available in the virtual environment.
pip install yolk yolk -l
We obtain a short list of packages
Python - 2.6.6 - active development (/usr/lib/python2.6/lib-dynload) distribute - 0.6.10 - active pip - 0.7.2 - active wsgiref - 0.1.2 - active development (/usr/lib/python2.6) yolk - 0.4.3 - active
Finally, we check the bin/activate script of our virtualenv to verify the value of the PYTHONPATH environment variable.
0 comments :
Post a Comment