Installed a CentOS 5.5, want to set up a python development environment, but still encountered a lot of problems, record the process:
1. Python Upgrade
View Python version
Python-vpython 2.4.3
Because the change of Python3 is very big, still want to use new version, Goole a piece, see Have a guide post:
Cd/usr/local/srcwget http://www.python.org/ftp/python/3.2/python-3.2a1.tgz--14:51:31--/ http Www.python.org/ftp/python/3.2/Python-3.2a1.tgzResolving www.python.org ... done. Connecting to www.python.org[82.94.164.162]:80 ... Connected. HTTP request sent, awaiting response ... oklength:11,258,272 [Application/x-tar] 5% [> ] 570,106 67.19k/s ETA 02:35
Unzip the installation:
TAR-ZXVF PYTHON-3.2A1.TGZCD python-3.2a1./configuremake Allmake Install
Here, when executing the./configure, the error was made because GCC was not installed because Python was written in C, so it needs to be compiled with GCC, so we need to install GCC first.
Installation completed, after installation of the following work:
Make Cleanmake Distclean
To view the version again:
$ Python3.2-vpython 3.2A1
2. The yum exception brought by Python upgrade
After the Python upgrade, it was found that Yum could not be used,
$ yum File "/usr/bin/yum", line except Keyboardinterrupt, E: ^syntaxerror:invalid syntax
Continue Google, find the guide sticker:
Reason: This is because Yum uses Python as the command interpreter, which can be found from the first line of the/usr/bin/yum file #!/usr/bin/python. Compatibility between Python versions is not very good, making 2. There is a syntax inconsistency between version X and version 3.0. The CentOS 5 comes with Yum with python2.4, and when the system upgrades Python to 2.6 or 3.0, a syntax explanation error occurs.
Workaround:
Very simple, one is to upgrade Yum, one is to modify the Yum interpreter for the old version of python2.4 (if you do not use overwrite upgrade)
The practice of upgrading Yum is not detailed;
Modify the Yum interpreter for the old version python2.4:
Vi/usr/bin/yum
Change the first line "#!/usr/bin/python" to "#!/usr/bin/python2.4"
Forget it, you can use it first: Modify the Yum configuration file to solve!
3. Building development tools
Reference Guide Stickers
"工欲善其事, its prerequisite", a good development tool can improve the efficiency of development; I've written a blog post that builds the Vim Python development environment in windows, but because of the obvious understanding of vim, and the prior Java development process of Eclipse preferences, So I still choose to use the Eclipse+pydev.
Before installing the ECPILPSE environment, you need to check the Java version in the system first
Confirm the version number of the GCJ, Linux comes with the Java environment:
# Rpm-qa | grep gcj Java-1.4.2-gcj-compat-1.4.2.0-40jpp.115libgcj-4.1.2-48.el5
Installing the JDKDownload the Jdk-6u23-linux-i586-rpm.bin and put it in the/usr/local/src/file
1, cd/usr/local/src/ #进入所放下载文件的目录2, chmod u+x jdk-6u23-linux-i586-rpm.bin #由于下载的安装文件没有x权限, so add x permissions to root user 3, ./jdk-6u23-linux-i586-rpm.bin #安装完成
After installation, check the version:
# Java-versionjava Version "1.6.0_17"
Install EclipseDownload Eclipse-sdk-3.6.1-linux-gtk-tar-gz to/usr/local/src/
1, cd/usr/local/src/ #进入下载的文件目录中2, tar-zxv-f eclipse-sdk-3.6.1-linux-gtk-tar-gz-c/usr/local/ #-c extracted to the directory, Automatically generate the Eclipse directory
/usr/local/eclipse/eclipse Start eclipse:
Or on the desktop to build a shortcut to start (in the Linux desktop blank, right-click, pop Up a dialog box, select "New Launcher",--"Create Shortcut" dialog box---Name: eclipse– command:/usr/local/eclipse/eclipse Browse to the install Eclipse directory, locate the Eclipse launcher---Click on the icon to browse to the directory where Eclipse is installed, find the ECLIPSE.XPM click in the directory-OK)
Configure Pydev
(1) Start Eclipse, select Help->install New software ...
(2) in Workwith type http://www.fabioz.com/pydev/updates, click Add,eclipse automatically search to Pydev plug-in, select it, step by step next to install
(3) To see if the Pydev is installed successfully, select Help->about eclipst->installation details to install the plug-in
(4) Configure the PyDev interpreter, select Windows->preferences->pydev->interpreter-python, click New, find your Python installation path, Select Python.exe, then select the specific libraries. Last OK
(5) Finally, the use of the PYDEV environment, in the top right corner of Eclipse shows which development environment is currently in use, choose Open Perspective->other->pydev->ok, you can switch to the PYDEV development environment
At this point, the Python development environment is set.
CentOS builds Python development environment