系统red hat6.7 也即centos6.7 python3.5.2 安装 django 之后 创建project 以及 import sqlite3
都出现 No module named ‘_sqlite3′
>>>importsqlite3 Traceback(mostrecentcalllast): File"<stdin>",line1,in<module> File"/opt/Python-3.5.0/python350/lib/python3.5/sqlite3/__init__.py",line23,in<module> fromsqlite3.dbapi2import* File"/opt/python-3.5.0/python350/lib/python3.5/sqlite3/dbapi2.py",line27,in<module> from_sqlite3import*
解决:
1、yum-yinstallsqlite-devel 2、cdPython-3.5.2(python源码安装文件解压后的文件夹) 3、./configure--enable-loadable-sqlite-extensions 4、make&&makeinstall
如果这几步还不行,就修改 Python-3.5.2文件夹里的setup.py文件以后,重复第三和第四步:
在 sqlite_inc_paths 中添加sqlite的include 路径
如:
sqlite_inc_paths=['/usr/include','/usr/include/sqlite','/usr/include/sqlite3','/usr/local/include','/usr/local/include/sqlite','/usr/local/include/sqlite3','~/share/software/python/sqlite-3.6.20/include',(~/share/software/python/sqlite-3.6.20是sqlite的安装路径) '~/share/software/python/sqlite-3.6.20/include/sqlite3',]
二、如果是python2.7出现 import sqlite3 找不到 _sqlite模块的问题,就简单多了
1、#find/-name_sqlite*.so /usr/lib64/python2.6/lib-dynload/_sqlite3.so 2、#whereispython2.7 python2:/usr/bin/python2.7/usr/bin/python2/usr/bin/python2.6/usr/lib/python2.6 /usr/lib64/python2.6/usr/local/bin/python2.7/usr/local/bin/python2.7-config/usr/local/bin/python2 /usr/local/lib/python2.7/usr/include/python2.6 3、cp/usr/lib64/python2.6/lib-dynload/_sqlite3.so/usr/local/lib/python2.7/lib-dynload/_sqlite3.so
ok,搞定!
转自:http://blog.csdn.net/jaket5219999/article/details/53512071
原文链接:https://www.f2er.com/centos/377155.html