2
我已經在linux上安裝了python3。在Python解釋器,我試過Python3將無法識別sqlite
import sqlite3
,並得到
ImportError: No module named '_sqlite3'
所以我安裝的SQLite與
sudo apt-get install libsqlite-dev
,然後重新編譯蟒蛇按照README文件的說明:
cd ~/Python-3.4.2;
./configure;
make;
make test;
和測試過程中出現了一個錯誤,說
[ 97/389] test_sqlite
test_sqlite skipped -- No module named '_sqlite3'
,然後當我完成了安裝和試運行相同的Python代碼,我還是得到了同樣的導入錯誤。我究竟做錯了什麼?
---編輯---
我試圖
pip install pysqlite
,並得到這個錯誤,這似乎是Python2.7和Python3.4之間的問題:
Downloading/unpacking pysqlite
Downloading pysqlite-2.6.3.tar.gz (76kB): 76kB downloaded
Running setup.py (path:/tmp/pip_build_plat/pysqlite/setup.py) egg_info for package pysqlite
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_plat/pysqlite/setup.py", line 85
print "Is sphinx installed? If not, try 'sudo easy_install sphinx'."
^
SyntaxError: Missing parentheses in call to 'print'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_plat/pysqlite/setup.py", line 85
print "Is sphinx installed? If not, try 'sudo easy_install sphinx'."
^
SyntaxError: Missing parentheses in call to 'print'
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_plat/pysqlite
Storing debug log for failure in /home/plat/.pip/pip.log
您正在嘗試安裝的軟件包與Python 3不兼容。 – 2015-02-24 18:00:53
問題是,您的Python是在*沒有* sqlite支持的情況下構建的*你在編譯時安裝了'sqlite'開發頭文件嗎? – 2015-02-24 18:01:58
這可能是[如何爲python3.4.2安裝pysqlite](http://stackoverflow.com/q/26438307)的一個騙局,但該帖子沒有回答。 – 2015-02-24 18:02:47