WSL: ImportError: невозможно импортировать имя 'textblob' - PullRequest
0 голосов
/ 19 марта 2020

Я установил NLTK и TextBlob на Python3 на WSL. Что бы я ни делал, я всегда получаю одну и ту же ошибку. Действительно, попытка установки показывает, что все пакеты установлены

$ sudo pip3 install -U textblob
The directory '/home/jlchulilla/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/jlchulilla/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already up-to-date: textblob in /usr/local/lib/python3.6/dist-packages
Requirement already up-to-date: nltk>=3.1 in /usr/local/lib/python3.6/dist-packages (from textblob)
Requirement already up-to-date: six in /usr/local/lib/python3.6/dist-packages (from nltk>=3.1->textblob)

Но когда я пытаюсь обновить corpora или использовать from textblob import TextBlob, это сообщение об ошибке:

$ python3 -m textblob.download_corpora
Traceback (most recent call last):
  File "/usr/lib/python3.6/subprocess.py", line 140, in <module>
    import threading
  File "/usr/lib/python3.6/threading.py", line 7, in <module>
    from traceback import format_exc as _format_exc
  File "/usr/lib/python3.6/traceback.py", line 5, in <module>
    import linecache
  File "/usr/lib/python3.6/linecache.py", line 11, in <module>
    import tokenize
  File "/mnt/c/Users/jlchu/Dropbox/oando/COVID-19/Supermercados online y covid_csv/prácticas NLTK/tokenize.py", line 1, in <module>
    from textblob import textblob
ImportError: cannot import name 'textblob'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/usr/local/lib/python3.6/dist-packages/textblob/__init__.py", line 2, in <module>
    from .blob import TextBlob, Word, Sentence, Blobber, WordList
  File "/usr/local/lib/python3.6/dist-packages/textblob/blob.py", line 28, in <module>
    import nltk
  File "/usr/local/lib/python3.6/dist-packages/nltk/__init__.py", line 99, in <module>
    from nltk.internals import config_java
  File "/usr/local/lib/python3.6/dist-packages/nltk/internals.py", line 11, in <module>
    import subprocess
  File "/usr/lib/python3.6/subprocess.py", line 142, in <module>
    import dummy_threading as threading
  File "/usr/lib/python3.6/dummy_threading.py", line 45, in <module>
    import threading
  File "/usr/lib/python3.6/threading.py", line 7, in <module>
    from traceback import format_exc as _format_exc
  File "/usr/lib/python3.6/traceback.py", line 5, in <module>
    import linecache
  File "/usr/lib/python3.6/linecache.py", line 11, in <module>
    import tokenize
  File "/mnt/c/Users/jlchu/Dropbox/oando/COVID-19/Supermercados online y covid_csv/prácticas NLTK/tokenize.py", line 1, in <module>     
    from textblob import textblob
ImportError: cannot import name 'textblob'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3.6/subprocess.py", line 140, in <module>
    import threading
  File "/usr/lib/python3.6/threading.py", line 7, in <module>
    from traceback import format_exc as _format_exc
ImportError: cannot import name 'format_exc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 62, in apport_excepthook
    import re, traceback
  File "/usr/lib/python3.6/traceback.py", line 5, in <module>
    import linecache
  File "/usr/lib/python3.6/linecache.py", line 11, in <module>
    import tokenize
  File "/mnt/c/Users/jlchu/Dropbox/oando/COVID-19/Supermercados online y covid_csv/prácticas NLTK/tokenize.py", line 1, in <module>     
    from textblob import textblob
  File "/usr/local/lib/python3.6/dist-packages/textblob/__init__.py", line 2, in <module>
    from .blob import TextBlob, Word, Sentence, Blobber, WordList
  File "/usr/local/lib/python3.6/dist-packages/textblob/blob.py", line 28, in <module>
    import nltk
  File "/usr/local/lib/python3.6/dist-packages/nltk/__init__.py", line 99, in <module>
    from nltk.internals import config_java
  File "/usr/local/lib/python3.6/dist-packages/nltk/internals.py", line 11, in <module>
    import subprocess
  File "/usr/lib/python3.6/subprocess.py", line 142, in <module>
    import dummy_threading as threading
  File "/usr/lib/python3.6/dummy_threading.py", line 45, in <module>
    import threading
  File "/usr/lib/python3.6/threading.py", line 7, in <module>
    from traceback import format_exc as _format_exc
ImportError: cannot import name 'format_exc'

Original exception was:
Traceback (most recent call last):
  File "/usr/lib/python3.6/subprocess.py", line 140, in <module>
    import threading
  File "/usr/lib/python3.6/threading.py", line 7, in <module>
    from traceback import format_exc as _format_exc
  File "/usr/lib/python3.6/traceback.py", line 5, in <module>
    import linecache
  File "/usr/lib/python3.6/linecache.py", line 11, in <module>
    import tokenize
  File "/mnt/c/Users/jlchu/Dropbox/oando/COVID-19/Supermercados online y covid_csv/prácticas NLTK/tokenize.py", line 1, in <module>     
    from textblob import textblob
ImportError: cannot import name 'textblob'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/usr/local/lib/python3.6/dist-packages/textblob/__init__.py", line 2, in <module>
    from .blob import TextBlob, Word, Sentence, Blobber, WordList
  File "/usr/local/lib/python3.6/dist-packages/textblob/blob.py", line 28, in <module>
    import nltk
  File "/usr/local/lib/python3.6/dist-packages/nltk/__init__.py", line 99, in <module>
    from nltk.internals import config_java
  File "/usr/local/lib/python3.6/dist-packages/nltk/internals.py", line 11, in <module>
    import subprocess
  File "/usr/lib/python3.6/subprocess.py", line 142, in <module>
    import dummy_threading as threading
  File "/usr/lib/python3.6/dummy_threading.py", line 45, in <module>
    import threading
  File "/usr/lib/python3.6/threading.py", line 7, in <module>
    from traceback import format_exc as _format_exc
  File "/usr/lib/python3.6/traceback.py", line 5, in <module>
    import linecache
  File "/usr/lib/python3.6/linecache.py", line 11, in <module>
    import tokenize
  File "/mnt/c/Users/jlchu/Dropbox/oando/COVID-19/Supermercados online y covid_csv/prácticas NLTK/tokenize.py", line 1, in <module>     
    from textblob import textblob
ImportError: cannot import name 'textblob'

Я не могу понять, в чем проблема. Любая помощь будет очень признательна

Редактировать: Когда я пытаюсь импортировать любой другой модуль библиотеки NLTK, происходит та же ошибка. Это как если бы предыдущий вызов tokenize заблокировал бы модуль или что-то в этом роде

$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from nltk.stem.porter import PorterStemmer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/nltk/__init__.py", line 99, in <module>
    from nltk.internals import config_java
  File "/usr/local/lib/python3.6/dist-packages/nltk/internals.py", line 11, in <module>
    import subprocess
  File "/usr/lib/python3.6/subprocess.py", line 140, in <module>
    import threading
  File "/usr/lib/python3.6/threading.py", line 7, in <module>
    from traceback import format_exc as _format_exc
  File "/usr/lib/python3.6/traceback.py", line 5, in <module>
    import linecache
  File "/usr/lib/python3.6/linecache.py", line 11, in <module>
    import tokenize
  File "/mnt/c/Users/jlchu/Dropbox/oando/COVID-19/Supermercados online y covid_csv/prácticas NLTK/tokenize.py", line 1, in <module>
    from textblob import TextBlob
  File "/usr/local/lib/python3.6/dist-packages/textblob/__init__.py", line 2, in <module>
    from .blob import TextBlob, Word, Sentence, Blobber, WordList
  File "/usr/local/lib/python3.6/dist-packages/textblob/blob.py", line 35, in <module>
    from textblob.base import (BaseNPExtractor, BaseTagger, BaseTokenizer,
  File "/usr/local/lib/python3.6/dist-packages/textblob/base.py", line 44, in <module>
    class BaseTokenizer(with_metaclass(ABCMeta), nltk.tokenize.api.TokenizerI):
AttributeError: module 'nltk' has no attribute 'tokenize'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3.6/subprocess.py", line 140, in <module>
    import threading
  File "/usr/lib/python3.6/threading.py", line 7, in <module>
    from traceback import format_exc as _format_exc
ImportError: cannot import name 'format_exc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 62, in apport_excepthook
    import re, traceback
  File "/usr/lib/python3.6/traceback.py", line 5, in <module>
    import linecache
  File "/usr/lib/python3.6/linecache.py", line 11, in <module>
    import tokenize
  File "/mnt/c/Users/jlchu/Dropbox/oando/COVID-19/Supermercados online y covid_csv/prácticas NLTK/tokenize.py", line 1, in <module>     
    from textblob import TextBlob
  File "/usr/local/lib/python3.6/dist-packages/textblob/__init__.py", line 2, in <module>
    from .blob import TextBlob, Word, Sentence, Blobber, WordList
  File "/usr/local/lib/python3.6/dist-packages/textblob/blob.py", line 28, in <module>
    import nltk
  File "/usr/local/lib/python3.6/dist-packages/nltk/__init__.py", line 99, in <module>
    from nltk.internals import config_java
  File "/usr/local/lib/python3.6/dist-packages/nltk/internals.py", line 11, in <module>
    import subprocess
  File "/usr/lib/python3.6/subprocess.py", line 142, in <module>
    import dummy_threading as threading
  File "/usr/lib/python3.6/dummy_threading.py", line 45, in <module>
    import threading
  File "/usr/lib/python3.6/threading.py", line 7, in <module>
    from traceback import format_exc as _format_exc
ImportError: cannot import name 'format_exc'

Original exception was:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/nltk/__init__.py", line 99, in <module>
    from nltk.internals import config_java
  File "/usr/local/lib/python3.6/dist-packages/nltk/internals.py", line 11, in <module>
    import subprocess
  File "/usr/lib/python3.6/subprocess.py", line 140, in <module>
    import threading
  File "/usr/lib/python3.6/threading.py", line 7, in <module>
    from traceback import format_exc as _format_exc
  File "/usr/lib/python3.6/traceback.py", line 5, in <module>
    import linecache
  File "/usr/lib/python3.6/linecache.py", line 11, in <module>
    import tokenize
  File "/mnt/c/Users/jlchu/Dropbox/oando/COVID-19/Supermercados online y covid_csv/prácticas NLTK/tokenize.py", line 1, in <module>     
    from textblob import TextBlob
  File "/usr/local/lib/python3.6/dist-packages/textblob/__init__.py", line 2, in <module>
    from .blob import TextBlob, Word, Sentence, Blobber, WordList
  File "/usr/local/lib/python3.6/dist-packages/textblob/blob.py", line 35, in <module>
    from textblob.base import (BaseNPExtractor, BaseTagger, BaseTokenizer,
  File "/usr/local/lib/python3.6/dist-packages/textblob/base.py", line 44, in <module>
    class BaseTokenizer(with_metaclass(ABCMeta), nltk.tokenize.api.TokenizerI):
AttributeError: module 'nltk' has no attribute 'tokenize'
...