Set Python environment variables in Linux
(14:41:24)
ReprintedBytes
Add environment variables mainly in/etc/profile
For example, you have installed python2.7 in/usr/local /.
Because the default value is 2.4
# Python
Python 2.4.3 (#1, SEP
3 2009, 15:37:37)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "Copyright", "Credits" or "License" for more information.
>>>
Go to the installation path of python2.7 and find the python file in/bin.
./Python
Python 2.7.2 (default, Feb 2 2012, 11:45:14)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "Copyright", "Credits" or "License" for more information.
>>>
First, check the current environment variables.
# Echo $ path
/Usr/local/jdk1.5/bin:/usr/Kerberos/sbin:/usr/Kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin: /bin:/usr/sbin:/usr/bin:/root/bin
No latest python2.7 is available by default.
I will go to the newly installed python2.7 directory to view
/Usr/local/Python/bin/python2.7
This is the Startup File of python2.7.
# Path = $ path:/usr/local/Python/bin/
# Echo $ path
/Usr/local/jdk1.5/bin:/usr/Kerberos/sbin:/usr/Kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin: /bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/Python/bin/
Add the newly installed/usr/local/Python/bin to the environment variable.
When we enter
# Python2.7
Python 2.7.2 (default, Feb 2 2012, 11:45:14)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "Copyright", "Credits" or "License" for more information.
>>>
Because the system will automatically search for and start the python2.7 file in the environment, but will first find the Startup File under/usr/bin
When # python is used, it still enters the default 2.4 system.
Go to/usr/bin, delete python, and establish a connection.
Ln-S/usr/local/Python/bin/python./Python
In this way, when we # python, We will directly enter the 2.7 environment.