python升级:
同事的程序是在Python 2.7.3写的,在python2.6.6下运行仿佛有问题!于是考虑升级到python2.7.3
升级步骤如下:
1:下载
wget
2:解压
tar jxvf Python-2.7.3.tar.bz2
3:编译安装
./configure
make all
make install
make clean
make distclean
/usr/local/bin/python2.7 -V
cd /usr/bin/
ls python
mv python python2.6.6
ln -s /usr/local/bin/python2.7 /usr/bin/python
ll python
[root@s4 loldbrtmp6]# python -V
Python 2.7.3
vi /usr/bin/yum #### 用于解决系统python软链接指向python2.7版本后,yum不能正常工作的问题
将文件头部的
#!/usr/bin/python
改成
#!/usr/bin/python2.6.6
make
在运行程序过程中也遇到几个问题:##缺少python 相关模块
1:
解决方法:
下载setuptools-0.7.2.tar.gz
tar zxvf setuptools-0.7.2.tar.gz
cd setuptools
python setup.py build
python setup.py install
2:
[root@s4 backupv2]# python start.py
Traceback (most recent call last):
File "start.py", line 2, in
import MySQLdb
ImportError: No module named MySQLdb
解决方法:
下载MySQL-python-1.2.3.tar.gz
tar zxvf MySQL-python-1.2.3.tar.gz
cd MySQL-python-1.2.3
-
[root@s4 MySQL-python-1.2.3]# cat site.cfg
-
[options]
-
# embedded: link against the embedded server library
-
# threadsafe: use the threadsafe client
-
# static: link against a static library (probably required for embedded)
-
-
embedded = False
-
threadsafe = True
-
static = False
-
-
# The path to mysql_config.
-
# Only use this if mysql_config is not on your PATH, or you have some weird
-
# setup that requires it.
-
mysql_config = /data/mysql/bin/mysql_config ####将注释去掉并修改为自己mysql的安装位置
-
-
# The Windows registry key for MySQL.
-
# This has to be set for Windows builds to work.
-
# Only change this if you have a different version.
-
registry_key = SOFTWARE\MySQL AB\MySQL Server 5.0
3:
解决方法如下:
4:ImportError: cannot import name OrderedDict
解决方法:
tar zxvf ordereddict-1.1.tar.gz ##该版本和python2.6.6.不匹配!
cd ordereddict-1.1
python setup.py build
python setup.py install
然后测试即可正常!
阅读(2089) | 评论(0) | 转发(0) |