python2.7.6比python2.7.3升级过程中import module问题及解决方法

时间:2022-01-07 07:57:06

1.python下“No module named sqlsoup”错误:
importerror:No module named sqlsoup
问题原因:sqlalchemy版本安装不对,解决方法:
https://github.com/downloads/facebook/tornado/tornado-2.4.1.tar.gz https://github.com/downloads/facebook/tornado/tornado-2.4.1.tar.gz pip uninstall sqlalchemy
pip install http://pypi.python.org/packages/source/S/SQLAlchemy/SQLAlchemy-0.7.9.tar.gz

2.python下“No module named tornado”错误:
ImportError: No module named tornado
解决方法:
下载tornado:

$wget https://github.com/downloads/facebook/tornado/tornado-2.4.1.tar.gz 

解压编译安装:

$tar -zxvf tornado-2.4.1.tar.gz

$ cd tornado-2.4.1

$ python setup.py build

$ python setup.py install


3.python下“No module named cjson”错误:
ImportError: No module named cjson
解决方法:
下载cjson:

进入以下网址:

http://packages.ubuntu.com/zh-cn/source/lucid-updates/i386/python-cjson

下载python-cjson_1.0.5.orig.tar.gz

解压编译安装:

$tar -zxvf python-cjson_1.0.5.orig.tar.gz

$ cdpython-cjson_1.0.5

$ python setup.py build

$ python setup.py install


4.python下“No module named mysqldb”错误:
ImportError: No module named
mysqldb

解决方法:

首先确保系统安装mysql,如果没有按照如下步骤安装:

1)安装python开发包:sudo apt-get install python-dev

2)安装mysql服务端、客户端及扩展包:

sudo apt-get install mysql-server mysql-client libmysqlclient-dev

3)安装python第三方库管理工具:sudo apt-get install  python-setuptools

4)安装Mysql-python库:sudo easy_install mysql-python

5)安装服务启动工具:sudo apt-get install sysv-rc-conf

6)修改mysql开机启动:sudo sysv-rc-conf --level 2345 mysql off

当然也可以参照如下链接安装mysql:

http://chinacheng.iteye.com/blog/1736651

然后安装mysqldb:

1)https://sourceforge.net/projects/mysql-python/ 下载源码
2)tar xvzf MySQL-python-1.2.4b4.tar.gz
3) cd MySQL-python-1.2.4b4/
4)利用whereis mysql_config查找mysql_config文件所在路径PATH,并将site.cfg中mysql_config后面路径替换为PATH。如果无法查找到mysql_config文件,则在4)之前执行步骤:sudo apt-get install libmysqlclient-dev

5)python setup.py build
6)sudo python setup.py install 


5.python下“No module named ldap”错误:
ImportError: No module named ldap

解决方法:

sudo apt-get install python-ldap


总结:针对ubuntu下python缺乏的软件包依赖,可以有如下通用安装方式:

首先去http://packages.ubuntu.com/zh-cn/lucid-updates/i386/python/下载对应的软件安装包

2)然后利用tar, unzip等命令进行解压缩

3)进入解压缩之后的目录

4)python setup.py build进行编译

5)sudo python setup.py install进行安装