Notions de bases Python
Installing Python
Unix and Linux Installation
Here are the simple steps to install Python on Unix/Linux machine.
● Open a Web browser and go to [Link]
● Follow the link to download zipped source code available for Unix/Linux.
● Download and extract files.
● Editing the Modules/Setup file if you want to customize some options.
● run ./configure script
● make
● make install
This installs Python at standard location /usr/local/bin and its libraries at
/usr/local/lib/pythonXX where XX is the version of Python.
Windows Installation
Here are the steps to install Python on Windows machine.
● Open a Web browser and go to [Link]
● Follow the link for the Windows installer [Link] file where XYZ is the
version you need to install.
Setting path at Unix/Linux
To add the Python directory to the path for a particular session in Unix −
● In the csh shell − type setenv PATH "$PATH:/usr/local/bin/python" and press
Enter.
● In the bash shell (Linux) − type export PATH="$PATH:/usr/local/bin/python"
and press Enter.
● In the sh or ksh shell − type PATH="$PATH:/usr/local/bin/python" and press
Enter.
● Note − /usr/local/bin/python is the path of the Python directory
Setting path at Windows
Running Python
There are three different ways to start Python −
Interactive Interpreter
You can start Python from Unix, DOS, or any other system that provides you a
command-line interpreter or shell window.
Enter python the command line.
Start coding right away in the interactive interpreter.
$python # Unix/Linux C:> python # Windows/DOS
Here is the list of all the available command line options −
[Link] Option & Description
.
1 -d It provides debug output.
2 -O It generates optimized bytecode (resulting in .pyo files).
3 -S Do not run import site to look for Python paths on startup.
4 -v verbose output (detailed trace on import statements).
5 -X disable class-based built-in exceptions (just use strings); obsolete
starting with version 1.6.
6 -c cmd : run Python script sent in as cmd string