Centos7 after installing Python3 and Django, Modulenotfounderror:no module named ' _sqlite3 '

Source: Internet
Author: User
Tags sqlite

1. Preparing the installation Environment

' Development Tools ' Yum install zlib-devel bzip2-devel openssl-devel ncurses-devel

2. Installing Python3

Go to the official website to download the compiled installation package or directly execute the following command

wget HTTPS://WWW.PYTHON.ORG/FTP/PYTHON/3.6.2/PYTHON-3.6.2.TAR.XZ

Extract

TAR-XVJF PYTHON-3.6.2.TAR.XZ

Switch into

CD Python-3.6.2

Compiling the installation

./configure Prefix=/usr/local/python3

Make && make install

After installation, there will be python3 in the/usr/local/directory.

So we can add a soft link to the execution directory under/usr/bin

Ln-s/usr/local/python3/bin/python3/usr/bin/python3

Ln-s/USR/LOCAL/PYTHON3/BIN/PIP3/USR/BIN/PIP3

[[Email protected] ~]#Python3Python 3.6.2 (Default, Nov 15 2017, 03:44:12) [GCC4.8.5 20150623 (Red Hat 4.8.5-16)] on Linuxtype" Help","Copyright","credits" or "License"  forMore information.>>>ImportSqlite3traceback (most recent): File"<stdin>", Line 1,inch<module>File"/usr/local/python3/lib/python3.6/sqlite3/__init__.py", line 23,inch<module> fromSqlite3.dbapi2Import*File"/usr/local/python3/lib/python3.6/sqlite3/dbapi2.py", line 27,inch<module> from_sqlite3Import*Modulenotfounderror:no module named'_sqlite3'

3. Installing Sqlite3

Official website http://www.sqlite.org/download.html

I downloaded: sqlite-autoconf-3210000.tar.gz

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

4. Installing Sqlite-devel

 yum install sqlite-devel

5. Recompile the installation Python3

Edit the python3.6.2 inside the setup.py and add the SQLite search path:
Open with Vim setup.py, enter:
The/sqlite_inc_paths #用于寻找该字段 as follows:

[Email protected] python-3.6.2]# vim setup.py

Ok

Centos7 after installing Python3 and Django, Modulenotfounderror:no module named ' _sqlite3 '

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.