Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2764738
  • 博文数量: 587
  • 博客积分: 6356
  • 博客等级: 准将
  • 技术积分: 6410
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-23 10:54
个人简介

器量大者,福泽必厚

文章分类

全部博文(587)

文章存档

2019年(3)

2018年(1)

2017年(29)

2016年(39)

2015年(66)

2014年(117)

2013年(136)

2012年(58)

2011年(34)

2010年(50)

2009年(38)

2008年(16)

分类: LINUX

2013-07-09 11:16:37

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

  1. [root@s4 MySQL-python-1.2.3]# cat site.cfg
  2. [options]
  3. # embedded: link against the embedded server library
  4. # threadsafe: use the threadsafe client
  5. # static: link against a static library (probably required for embedded)

  6. embedded = False
  7. threadsafe = True
  8. static = False

  9. # The path to mysql_config.
  10. # Only use this if mysql_config is not on your PATH, or you have some weird
  11. # setup that requires it.
  12. mysql_config = /data/mysql/bin/mysql_config ####将注释去掉并修改为自己mysql的安装位置

  13. # The Windows registry key for MySQL.
  14. # This has to be set for Windows builds to work.
  15. # Only change this if you have a different version.
  16. 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
然后测试即可正常!
阅读(2056) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~