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



我正在使用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 命令,但这会导致不同的错误,所以我推断这不是答案。

有谁知道这里可能发生了什么?

sqlite3 是 python 模块(用 python 编写(,用于包装_sqlite3(C 模块(以使其看起来更像 python。

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

相关内容

  • 没有找到相关文章

最新更新