码迷,mamicode.com
首页 > 数据库 > 详细

centos7安装python3和Django后,ModuleNotFoundError: No module named '_sqlite3'

时间:2017-11-14 20:35:02      阅读:3396      评论:0      收藏:0      [点我收藏+]

标签:打开   解压   ati   develop   last   zip   reg   技术分享   err   

 1.准备安装环境

yum groupinstall Development Tools
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel

2.安装python3

去官网下载编译安装包或者直接执行以下命令下载

wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz

解压

tar -xvJf  Python-3.6.2.tar.xz

切换进入

cd Python-3.6.2

编译安装

./configure prefix=/usr/local/python3

make && make install

安装完毕,/usr/local/目录下就会有python3了

因此我们可以添加软链到执行目录下/usr/bin

ln -s /usr/local/python3/bin/python3 /usr/bin/python3

ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

技术分享

技术分享

[root@greg02 ~]# python3
Python 3.6.2 (default, Nov 15 2017, 03:44:12) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/python3/lib/python3.6/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/python3/lib/python3.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named _sqlite3

 3.安装sqlite3

官网http://www.sqlite.org/download.html

我下载的是:sqlite-autoconf-3210000.tar.gz

configure –prefix=/usr/local/sqlite3
make 
make install

技术分享

4.安装 sqlite-devel

 yum install sqlite-devel

5.重新编译安装Python3

编辑python3.6.2里面的setup.py,  添加sqlite的搜索路径: 
使用vim setup.py 打开,输入: 
/sqlite_inc_paths #用于寻找该字段,如下所示:

[root@greg02 Python-3.6.2]# vim setup.py 

技术分享

技术分享

OK

centos7安装python3和Django后,ModuleNotFoundError: No module named '_sqlite3'

标签:打开   解压   ati   develop   last   zip   reg   技术分享   err   

原文地址:http://www.cnblogs.com/gregoryli/p/7834424.html

(2)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!