sqlite3错误
import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.3/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.3/sqlite3/dbapi2.py", line 26, in <module>
from _sqlite3 import *
ImportError: No module named '_sqlite3'
我使用sqlite3安装命令
pip install pysqlite
Downloading/unpacking pysqlite
Downloading pysqlite-2.6.3.tar.gz (76kB): 76kB downloaded
Running setup.py egg_info for package pysqlite
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/usr/local/lib/python3.3/codecs.py", line 300, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 98: invalid continuation byte
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/usr/local/lib/python3.3/codecs.py", line 300, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 98: invalid continuation byte
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/pysqlite
Storing complete log in /root/.pip/pip.log
答案 0 :(得分:18)
我是Fedora 20用户。要解决这个问题:
使用以下命令安装sqlite-devel软件包:
yum install sqlite-devel
安装完成后,使用以下命令从源代码重新编译python:
./configure
make && make install
对于多个版本的Python,请使用altinstall
代替install
。
答案 1 :(得分:9)
我认为一定是你不能安装sqlite3,你可以这样做
apt-get install sqlite3
sqlite3 -version
apt-get install python-pysqlite2
apt-get install python-pysqlite2-dbg
apt-get install libsqlite3-dev
apt-get install sqlite
pip install pysqlite
然后你会找到sqlite3
答案 2 :(得分:2)
编译包缺少某些东西,你应该使用yum 安装这5个,然后重新编译并安装python3
yum install readline-devel
yum install tk-devel
yum install tcl-devel
yum install openssl-devel
yum install sqlite-devel
然后重新编译python3
tar Jxvf Python-3.5.0.tar.xz
cd Python-3.5.0
./configure --prefix=/usr/local/python3
make && make install
答案 3 :(得分:2)
对于Ubuntu中的Python3:
sudo apt-get install libsqlite3-dev
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz
(用python3版本替换版本号)tar -xf Python-3.6.3.tar.xz
cd Python-3.6.3/
./configure --enable-loadable-sqlite-extensions && make && sudo make install
答案 4 :(得分:0)
我在使用编译的3.5.7时碰到了这个问题
wget https://www.python.org/ftp/python/3.5.7/Python-3.5.7.tgz
tar xvfz Python-3.5.7.tgz
cd Python-3.5.7
./configure --enable-optimizations
sudo make altinstall
# python3.5
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.5/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named '_sqlite3'
yum install sqlite-devel
re-compile python 3.5 from source