centos虚拟机安装升级版的python2.7问题

#@牧飞 
#python2.7
gunzip Python-2.7.6.tgz
tar xvf Python-2.7.6.tar
cd Python-2.7.6
./configure
make && make install

#setuptools
#wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
tar zxvf setuptools-0.6c11.tar.gz
cd setuptools-0.6c11
python2.7 setup.py build
python2.7 setup.py install

#pip2.7
unzip pip-master.zip
cd pip-master
python2.7 setup.py install
pip -V

#requests
pip2.7 install requests

#twisted
pip2.7 install twisted

###以后在py文件顶部添加#!/usr/bin/python2.7即可
###因centos的yum可能使用旧版python2.4
###以后执行使用pyhon2.7,安装pip2.7

#redis
pip2.7 install redis

#config
pip2.7 install config

#MySQLdb
pip2.7 install MySQLdb


#* 安装MySQLdb报错可能需要安装MySQL-python(yum install MySQL-python)
#sh: mysql_config: not found
#Traceback (most recent call last):
#  File "setup.py", line 15, in 
#    metadata, options = get_config()
#  File "/home/zhxia/apps/source/MySQL-python-1.2.5/setup_posix.py", line 43, in get_config
#    libs = mysql_config("libs_r")
#  File "/home/zhxia/apps/source/MySQL-python-1.2.5/setup_posix.py", line 24, in mysql_config
#    raise EnvironmentError("%s not found" % (mysql_config.path,))
#EnvironmentError: mysql_config not found
#只要原因是没有安装:libmysqlclient-dev
#sudo apt-get install libmysqlclient-dev
#找到mysql_config文件的路径
#sudo updatedb
locate mysql_config
#mysql_config的位置为:/usr/bin/mysql_config
#在mysql-python源码包下找到:setup_posix.py 文件,然后找到文件中的 mysql_config.path 将其值改为:/usr/bin/mysql_config,然后 sudo python setup.py install ,就ok了

#今天尝试使用MySQLdb数据库结果发现安装好MySQLdb我们导入数据时提示了ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory不是一个有效的目录了,下面我就来把解决方法与各位分享一下。
#根据最后提示,应该是找不着一个交libmysqlclient.so.18的文件,于是到mysql安装目录里找到这个文件并且做一个软连接到/usr/lib
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
#如果是64系统则:
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18

#--------------------------------------------------------------------------------------------------------------------------
#* 遭遇MySQLdb1.2.3读取datetime类型字段的解决方案
#* 发现在读取datetime类型字段时会出现None
#* https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.5.zip#md5=654f75b302db6ed8dc5a898c625e030c
#* 下载了最新的MySQL-python1.2.5,安装上去,然后问题就解决了 //好像我的ubuntu没有问题
#* python3以后不再支持MySQLdb, 请使用pymysql


 
  
附件下载
http://download.csdn.net/detail/qq_20154743/9565432?user=牧飞

你可能感兴趣的:(python)