Skip to main content
 首页 » 编程设计

Python 2.7 没有名为 _sqlite3 的模块(没有根访问机器,本地安装了 python)

2025年05月04日8telwanggs

可能还有其他类似的问题,但在我的特殊情况下,我没有 super 用户 (sudo) 访问机器,并且我在本地安装了 Python 2.7。

>>> 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 
>>>  

更新:当我运行 ./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 

请您参考如下方法:

也遇到了这个问题.. 通过编译 Python 并在 ./configure 期间传递 sqlite3 header /库来修复

Python 2.7.3 _sqlite3 module is not being built after passing headers/libraries

张贴以防其他人将来遇到此问题并且没有对节点的 sudo 访问权限。