2012-02-20 103 views
2

可能還有類似的其他問題,但在我的特殊情況下,我沒有超級用戶(sudo)訪問機器,並且我已經在本地安裝了Python 2.7。Python 2.7沒有名爲_sqlite3的模塊(沒有root權限訪問機器,本地安裝python)?

>>> import sqlite3 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/home/spicmacay/.local/lib/python2.7/sqlite3/__init__.py", line 24, in <module> 
    from dbapi2 import * 
    File "/home/spicmacay/.local/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module> 
    from _sqlite3 import * 
ImportError: No module named _sqlite3 
>>> 

UPDATE:當我運行./configure&& make,我得到:

make 

running build 
running build_ext 
building dbm using gdbm 
INFO: Can't locate Tcl/Tk libs and/or headers 

Python build finished, but the necessary bits to build these modules were not found: 
_sqlite3   _tkinter   bsddb185   
dl     imageop   sunaudiodev  
To find the necessary bits, look in setup.py in detect_modules() for the module's name. 

running build_scripts 
+1

如果你編譯了python,你可能忘記了sqlite庫嗎? – Marii 2012-02-20 15:24:59

回答

2

這發生在我最近。你需要apt-get install libsqlite3-dev(在Debian上 - sqlite-devel可能在其他地方)並重新編譯python。

+2

你在這裏看到的(沒有根訪問) – prongs 2012-02-20 15:52:00

+0

,你將需要找到如果可能,庫的二進制和手動把它們的地方,蟒蛇可以拾取它們編譯 – 2012-02-20 16:04:02

-2

嘗試增加sudo命令apt-get install libsqlite3-dev之前擺脫「無根訪問權限」,即在終端

,寫:

sudo apt-get install libsqlite3-dev 
+4

是的,如果你有sudo訪問sudo的只能當...... – prongs 2012-02-20 16:07:22

1

如果第一./configure sqlite3的一個--prefix選項,然後makemake install,然後編譯Python的時候使用同一--prefix,Python的安裝就能神奇地找到並使用您剛纔安裝的sqlite3的。

cd sqlite-autoconf-3080100 
./configure --prefix=/home/xdanek7/appscale/local 
make 
make install 
cd ../Python-2.7.6 
./configure --prefix=/home/xdanek7/appscale/local 
make 
make install 
相關問題