zoukankan      html  css  js  c++  java
  • centos7安装python3和Django后,ModuleNotFoundError: No module named '_sqlite3'

     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

  • 相关阅读:
    2019 | 开启新的堕落生活
    2018博客之星评选,我非常需要您宝贵的一票!♪(・ω・)ノ
    前端开发 2018 回顾
    全栈设计模式套餐MVVM, RESTful, MVC的历史探索
    停止学习框架
    那些被浏览器阻止的模拟事件...
    Just Cause系列游戏品鉴
    GPU硬件加速原理 /转
    快速上手最棒的网格框架ag-Grid
    用户数据验证的正确姿势之assert
  • 原文地址:https://www.cnblogs.com/ningxin18/p/7834424.html
Copyright © 2011-2022 走看看