ImportError:没有名为'_sqlite3'的模块错误 - 下划线相关性?

时间:2017-02-15 15:14:13

标签: python python-3.x sqlite python-newspaper

我正在使用Python3.4,我最近从python 3.3.2升级。

我正在按照这些说明安装如何安装python库/工具的报纸。

https://github.com/codelucas/newspaper

执行此命令后出现错误:

curl https://raw.githubusercontent.com/codelucas/newspaper/master/download_corpora.py | python3

注意:我已经  在上面的命令中也指定了python3.4 我得到相同/以下输出/错误:

import sqlite3
  File "/usr/local/lib/python3.4/sqlite3/__init__.py", line 23, in <module>
    from sqlite3.dbapi2 import *
  File "/usr/local/lib/python3.4/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ImportError: No module named '_sqlite3'
[root@neil bin]# curl https://raw.githubusercontent.com/codelucas/newspaper/master/download_corpora.py | python3.4
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   657  100   657    0     0    206      0  0:00:03  0:00:03 --:--:--   206
Traceback (most recent call last):
  File "<stdin>", line 6, in <module>
  File "/usr/local/lib/python3.4/site-packages/nltk/__init__.py", line 137, in <module>
    from nltk.stem import *
  File "/usr/local/lib/python3.4/site-packages/nltk/stem/__init__.py", line 29, in <module>
    from nltk.stem.snowball import SnowballStemmer
  File "/usr/local/lib/python3.4/site-packages/nltk/stem/snowball.py", line 24, in <module>
    from nltk.corpus import stopwords
  File "/usr/local/lib/python3.4/site-packages/nltk/corpus/__init__.py", line 66, in <module>
    from nltk.corpus.reader import *
  File "/usr/local/lib/python3.4/site-packages/nltk/corpus/reader/__init__.py", line 105, in <module>
    from nltk.corpus.reader.panlex_lite import *
  File "/usr/local/lib/python3.4/site-packages/nltk/corpus/reader/panlex_lite.py", line 15, in <module>
    import sqlite3
  File "/usr/local/lib/python3.4/sqlite3/__init__.py", line 23, in <module>
    from sqlite3.dbapi2 import *
  File "/usr/local/lib/python3.4/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ImportError: No module named '_sqlite3'

所以我看了/usr/local/lib/python3.4/sqlite3/dbapi2.py

此脚本确实尝试从_sqilte3导入:

from _sqlite3 import *

我删除了下划线并再次尝试了原始的curl命令,但这会导致不同的错误,所以我推断出这不是答案。

有谁知道这里会发生什么?

1 个答案:

答案 0 :(得分:5)

sqlite3是用于包装_sqlite3(一个c模块)的python模块(用python编写),使其看起来更加pythonic。

显然您缺少二进制模块,因此无法从那里导入。更改导入字符串会给您带来很多错误,因为这些模块实际上是不同的。尝试重新安装python,至少对我来说_sqlite3二进制模块是由python本身拥有的。