gpt4 book ai didi

python-3.x - python3.6导入sqlite3报错

转载 作者:IT王子 更新时间:2023-10-29 06:20:17 25 4
gpt4 key购买 nike

我在ubuntu16.04上安装了Python3.6,安装了sqlite3。在 python2 中,我可以成功导入 sqlite,但是在 python3 中,我遇到了导入错误。谷歌试了很多方法,还是不行。我想知道如何解决它。

Python 3.6.0 (default, Mar 13 2017, 06:38:19) 
[GCC 5.4.0 20160609] 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/lib/python3.6/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *

ModuleNotFoundError: No module named '_sqlite3'

最佳答案

sqlite3 将自带 python 本身。我也遇到了同样的问题,我刚刚卸载了 python3.6 并重新安装。

卸载现有的python:

sudo apt-get remove --purge python3.6

安装python3.6:

sudo apt install -y \
build-essential \
checkinstall

sudo apt install -y \
libreadline-gplv2-dev \
libncursesw5-dev \
libssl-dev \
libsqlite3-dev \
tk-dev \
libgdbm-dev \
libc6-dev \
libbz2-dev

PYTHON_VERSION=3.6.0

wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz
tar xvf Python-${PYTHON_VERSION}.tar.xz
cd Python-${PYTHON_VERSION}/
./configure
sudo make altinstall

有效!

关于python-3.x - python3.6导入sqlite3报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42766063/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com