download
installation
Configuration
Environment variable configuration
Programs and executable files can be in many directories, and these paths are probably not in the search path provided by the operating system for executable files.
path (path) is stored in an environment variable, which is a named string maintained by the operating system. These variables contain information about available command line interpreters and other programs.
The path variable in Unix or Windows is PATH (UNIX is case sensitive, Windows is not case sensitive).
In Mac OS, the python installation path was changed during the installation process. If you need to reference Python in other directories, you must add the Python directory to the path.
Setting environment variables on Unix / Linux
-
In the csh shell:
Input
setenv PATH "$PATH:/usr/local/bin/python"
, Press "Enter".
-
In the bash shell (Linux):
enterexport PATH="$PATH:/usr/local/bin/python"
And press "Enter".
-
In sh or ksh shell:
Input
PATH="$PATH:/usr/local/bin/python"
, Press "Enter".
Note: / usr / local / bin / python is the installation directory of Python.
Setting environment variables in Windows
Add the Python directory in the environment variable:
-
In the command prompt box (cmd):
Input
path=%path%;C:\Python
And press "Enter".
Note: C: \ Python is the installation directory of Python.
run
$ python
hello.py
print 'hello'
$ python hello.py