Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot import name 'open' from 'smart_open'

I was doing this and got this error :

from gensim.models import Word2Vec

ImportError: cannot import name 'open' from 'smart_open' (C:\ProgramData\Anaconda3\lib\site-packages\smart_open\__init__.py)

Then I did this :

import smart_open
dir(smart_open)

['BZ2File','BytesIO','DEFAULT_ERRORS','IS_PY2','P','PATHLIB_SUPPORT','SSLError','SYSTEM_ENCODING','Uri','__builtins__','__cached__','__doc__','__file__','__loader__','__name__','__package__','__path__','__spec__','boto','codecs','collections','gzip','hdfs','http','importlib','io','logger','logging','os','pathlib','pathlib_module','requests','s3','s3_iter_bucket','six','smart_open','smart_open_hdfs','smart_open_http','smart_open_lib','smart_open_s3','smart_open_webhdfs','sys','urlparse','urlsplit','warnings','webhdfs']

As you can see there is no 'open' in it so how should I solve this. I tried to install different versions and I upgraded all version too.

like image 288
Abhishek Prajapat Avatar asked Jun 03 '20 19:06

Abhishek Prajapat


Video Answer


2 Answers

import smart_open
smart_open.open = smart_open.smart_open
from gensim.models import Word2Vec

Works well.

like image 143
Shooter Avatar answered Sep 22 '22 03:09

Shooter


I also got the same error. I resolved it by updating the smart_open to version 2.0.0.

conda install smart_open==2.0.0

or

pip install smart_open==2.0.0.

like image 31
Prasanth Kumar Avatar answered Sep 22 '22 03:09

Prasanth Kumar