модуль 'smart_open' не имеет атрибута 'local_file' - PullRequest
2 голосов
/ 13 апреля 2020

Я написал этот код

import gensim
from gensim import corpora
AttributeError                            Traceback (most recent call last)
<ipython-input-29-a29f5eabd8f4> in <module>
     85 # use the following command in anaconda prompt with the admionistrator privileges to install gensim
     86 # conda install -c conda-forge gensim
---> 87 import gensim
     88 from gensim import corpora
     89 

~\Anaconda3\lib\site-packages\gensim\__init__.py in <module>
      3 """
      4 
----> 5 from gensim import parsing, corpora, matutils, interfaces, models, similarities, summarization, utils  # noqa:F401
      6 import logging
      7 

~\Anaconda3\lib\site-packages\gensim\parsing\__init__.py in <module>
      2 
      3 from .porter import PorterStemmer  # noqa:F401
----> 4 from .preprocessing import (remove_stopwords, strip_punctuation, strip_punctuation2,  # noqa:F401
      5                             strip_tags, strip_short, strip_numeric,
      6                             strip_non_alphanum, strip_multiple_whitespaces,

~\Anaconda3\lib\site-packages\gensim\parsing\preprocessing.py in <module>
     40 import glob
     41 
---> 42 from gensim import utils
     43 from gensim.parsing.porter import PorterStemmer
     44 

~\Anaconda3\lib\site-packages\gensim\utils.py in <module>
     43 from six.moves import range
       44 
---> 45 from smart_open import open
     46 
     47 from multiprocessing import cpu_count

~\Anaconda3\lib\site-packages\smart_open\__init__.py in <module>
     26 from smart_open import version
     27 
---> 28 from .smart_open_lib import open, parse_uri, smart_open, register_compressor
     29 from .s3 import iter_bucket as s3_iter_bucket
     30 

~\Anaconda3\lib\site-packages\smart_open\smart_open_lib.py in <module>
     35 
     36 from smart_open import compression
---> 37 from smart_open import doctools
     38 from smart_open import transport
     39 from smart_open import utils

~\Anaconda3\lib\site-packages\smart_open\doctools.py in <module>
     19 
     20 from . import compression
---> 21 from . import transport
     22 
     23 PLACEHOLDER = '    smart_open/doctools.py magic goes here'

~\Anaconda3\lib\site-packages\smart_open\transport.py in <module>
     20 NO_SCHEME = ''
     21 
---> 22 _REGISTRY = {NO_SCHEME: smart_open.local_file}
     23 
     24 

AttributeError: module 'smart_open' has no attribute 'local_file'

Я получил ошибку: модуль 'smart_open' не имеет атрибута 'local_file', как я могу ее решить?

Ответы [ 4 ]

2 голосов
/ 20 апреля 2020

Я делаю smart_open понижением до 1.9.0 и делаю gensim понижением до 3.4.0, это работает для меня.

0 голосов
/ 29 апреля 2020

Я установил gensim, который имел smart_open-1.11.1 и столкнулся с той же проблемой. Я не уверен, что в последней версии есть какая-то ошибка или нет, но сработало понижение версии smart_open-1.11.1 до smart_open-1.9.0.

0 голосов
/ 22 апреля 2020

Потерялся в одной и той же ошибке в течение нескольких дней. Наконец, сработало ниже

  1. Откройте ~ \ Anaconda3 \ lib \ site-packages \ smart_open \ transport.py в вашем редакторе
  2. Go в строку 22, измените _REGISTRY = {NO_SCHEME: smart_open.local_file} на "_REGISTRY = {NO_SCHEME: smart_open_lib .local_file}"
  3. Добавьте строку import smart_open_lib в начале файл вместе с другими импортами
0 голосов
/ 20 апреля 2020

Получил ту же проблему и обновление версии smart_open помогло

python -m pip install --upgrade smart_open

В случае с conda обновление зависимостей должно помочь

conda install -c anaconda --update-deps gensim
...