首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >模块“smart_open”没有属性“local_file”

模块“smart_open”没有属性“local_file”
EN

Stack Overflow用户
提问于 2020-04-13 13:49:24
回答 5查看 4K关注 0票数 4

我已经写了这段代码

代码语言:javascript
运行
复制
import gensim
from gensim import corpora
代码语言:javascript
运行
复制
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’,我该如何解决它?

EN

回答 5

Stack Overflow用户

发布于 2020-04-20 22:27:20

我让smart_open降级到1.9.0,让gensim降级到3.4.0,这对我很有效。

票数 5
EN

Stack Overflow用户

发布于 2021-01-03 18:06:55

我就是这么干的,

首先,如果还没有安装gensimsmart_open,可以使用以下命令来完成:

代码语言:javascript
运行
复制
pip install gensim==3.4.0
pip install smart_open==1.9.0

在此之后,可以简单地导入包,

代码语言:javascript
运行
复制
import smart_open
import gensim

请确保先导入smart_open

票数 4
EN

Stack Overflow用户

发布于 2020-04-20 21:03:42

遇到同样的问题,升级smart_open版本有帮助

代码语言:javascript
运行
复制
python -m pip install --upgrade smart_open

在conda的情况下,更新依赖项应该可以解决这个问题

代码语言:javascript
运行
复制
conda install -c anaconda --update-deps gensim
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61182206

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档