Gensim: Gensim import failure on Debian

Created on 28 Sep 2016  路  11Comments  路  Source: RaRe-Technologies/gensim

I'm running a VM on Google Cloud Platform using Jupyter notebook with word2vec models.

I use a virtualenv environment in my setup to isolate my python packages and my import of gensim (i.e. import gensim) fails when I have checked all my dependencies should be the same.

The full trace of the error I see:

import gensim

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-a0f9ae4f40a8> in <module>()
      3 import json
      4 import csv
----> 5 import gensim
      6 from elasticsearch import Elasticsearch
      7 

/home/andraz.hribernik/venv/local/lib/python2.7/site-packages/gensim/__init__.py in <module>()
      4 """
      5 
----> 6 from gensim import parsing, matutils, interfaces, corpora, models, similarities, summarization
      7 import logging
      8 

/home/andraz.hribernik/venv/local/lib/python2.7/site-packages/gensim/models/__init__.py in <module>()
     16 from .phrases import Phrases
     17 
---> 18 from . import wrappers
     19 
     20 from gensim import interfaces, utils

/home/andraz.hribernik/venv/local/lib/python2.7/site-packages/gensim/models/wrappers/__init__.py in <module>()
      3 """
      4 
----> 5 from .ldamallet import LdaMallet
      6 from .dtmmodel import DtmModel
      7 from .ldavowpalwabbit import LdaVowpalWabbit

/home/andraz.hribernik/venv/local/lib/python2.7/site-packages/gensim/models/wrappers/ldamallet.py in <module>()
     38 
     39 from six import iteritems
---> 40 from smart_open import smart_open
     41 
     42 from gensim import utils, matutils

/home/andraz.hribernik/venv/local/lib/python2.7/site-packages/smart_open/__init__.py in <module>()
----> 1 from .smart_open_lib import *

/home/andraz.hribernik/venv/local/lib/python2.7/site-packages/smart_open/smart_open_lib.py in <module>()
     33     import http.client as httplib
     34 
---> 35 from boto.compat import BytesIO, urlsplit, six
     36 import boto.s3.key
     37 

/home/andraz.hribernik/venv/local/lib/python2.7/site-packages/boto/__init__.pyc in <module>()
   1214     return storage_uri(uri_str)
   1215 
-> 1216 boto.plugin.load_plugins(config)

AttributeError: 'module' object has no attribute 'plugin'

My system build is Debian GNU/Linux Jessie

Thanks

Most helpful comment

had the same problem, in case anyone stumbles upon this: GCE is broken somehow

pip install google-compute-engine
from https://github.com/GoogleCloudPlatform/compute-image-packages/issues/262

works

All 11 comments

Hi, thanks for reporting. Does import boto work for you?

Closing as abanddoned

had the same problem, in case anyone stumbles upon this: GCE is broken somehow

pip install google-compute-engine
from https://github.com/GoogleCloudPlatform/compute-image-packages/issues/262

works

@AdrianLoer Thanks a lot for posting the fix!

Hey, unfortunately the fix from @AdrianLoer doesn't work for me. Still getting the same error as the original poster.
I use a Ubuntu1604lts on a google cloud instance

AttributeError                            Traceback (most recent call last)
<ipython-input-25-284dfec6dca2> in <module>()
      1 get_ipython().magic('matplotlib inline')
      2 import importlib
----> 3 import utils2; importlib.reload(utils2)
      4 from utils2 import *
      5 from vgg16_avg import VGG16_Avg

~/courses/deeplearning2/utils2.py in <module>()
     10 from IPython.display import display, Audio
     11 from numpy.random import normal
---> 12 from gensim.models import word2vec
     13 from keras.preprocessing.text import Tokenizer
     14 from nltk.tokenize import ToktokTokenizer, StanfordTokenizer

~/anaconda3/lib/python3.6/site-packages/gensim/__init__.py in <module>()
      4 """
      5 
----> 6 from gensim import parsing, matutils, interfaces, corpora, models, similarities, summarization, utils  # noqa:F401
      7 import logging
      8 

~/anaconda3/lib/python3.6/site-packages/gensim/models/__init__.py in <module>()
     21 from .ldaseqmodel import LdaSeqModel  # noqa:F401
     22 
---> 23 from . import wrappers  # noqa:F401
     24 
     25 from gensim import interfaces, utils

~/anaconda3/lib/python3.6/site-packages/gensim/models/wrappers/__init__.py in <module>()
      3 """
      4 
----> 5 from .ldamallet import LdaMallet  # noqa:F401
      6 from .dtmmodel import DtmModel  # noqa:F401
      7 from .ldavowpalwabbit import LdaVowpalWabbit  # noqa:F401

~/anaconda3/lib/python3.6/site-packages/gensim/models/wrappers/ldamallet.py in <module>()
     38 
     39 import numpy
---> 40 from smart_open import smart_open
     41 
     42 from gensim import utils, matutils

~/anaconda3/lib/python3.6/site-packages/smart_open/__init__.py in <module>()
----> 1 from .smart_open_lib import *

~/anaconda3/lib/python3.6/site-packages/smart_open/smart_open_lib.py in <module>()
     40 
     41 from boto.compat import BytesIO, urlsplit, six
---> 42 import boto.s3.connection
     43 import boto.s3.key
     44 from ssl import SSLError

~/anaconda3/lib/python3.6/site-packages/boto/s3/connection.py in <module>()
     28 import time
     29 
---> 30 from boto.auth import detect_potential_s3sigv4
     31 import boto.utils
     32 from boto.connection import AWSAuthConnection

~/anaconda3/lib/python3.6/site-packages/boto/__init__.py in <module>()
   1214     return storage_uri(uri_str)
   1215 
-> 1216 boto.plugin.load_plugins(config)

AttributeError: module 'boto' has no attribute 'plugin'

@jamsawamsa what's versions of gensim, smart_open, boto you use? Can you update gensim/smart_open and reproduce your problem?

pip install --upgrade gensim smart_open

I didn't check the versions, but the upgrades worked. Thanks!

I'm now having the same issue, and the upgrade don't seem to work.

This is my error log:
`AttributeError Traceback (most recent call last)
in ()
1 import copy
----> 2 import gensim
3 import logging
4 import pyndri
5 import pyndri.compat

/home/dror_guldin/.local/lib/python3.5/site-packages/gensim/__init__.py in ()
4 """
5
----> 6 from gensim import parsing, matutils, interfaces, corpora, models, similarities, summarization, utils # noqa:F401
7 import logging
8

/home/dror_guldin/.local/lib/python3.5/site-packages/gensim/models/__init__.py in ()
20 from .atmodel import AuthorTopicModel # noqa:F401
21 from .ldaseqmodel import LdaSeqModel # noqa:F401
---> 22 from .fasttext import FastText # noqa:F401
23
24 from . import wrappers # noqa:F401

/home/dror_guldin/.local/lib/python3.5/site-packages/gensim/models/fasttext.py in ()
33
34 from gensim.models.word2vec import Word2Vec, train_sg_pair, train_cbow_pair
---> 35 from gensim.models.wrappers.fasttext import FastTextKeyedVectors
36 from gensim.models.wrappers.fasttext import FastText as Ft_Wrapper, compute_ngrams, ft_hash
37

/home/dror_guldin/.local/lib/python3.5/site-packages/gensim/models/wrappers/__init__.py in ()
3 """
4
----> 5 from .ldamallet import LdaMallet # noqa:F401
6 from .dtmmodel import DtmModel # noqa:F401
7 from .ldavowpalwabbit import LdaVowpalWabbit # noqa:F401

/home/dror_guldin/.local/lib/python3.5/site-packages/gensim/models/wrappers/ldamallet.py in ()
40
41 import numpy
---> 42 from smart_open import smart_open
43
44 from gensim import utils, matutils

/home/dror_guldin/.local/lib/python3.5/site-packages/smart_open/__init__.py in ()
----> 1 from .smart_open_lib import *

/home/dror_guldin/.local/lib/python3.5/site-packages/smart_open/smart_open_lib.py in ()
32
33 from boto.compat import BytesIO, urlsplit, six
---> 34 import boto.s3.connection
35 import boto.s3.key
36 from ssl import SSLError

/home/dror_guldin/.local/lib/python3.5/site-packages/boto/s3/connection.py in ()
28 import time
29
---> 30 from boto.auth import detect_potential_s3sigv4
31 import boto.utils
32 from boto.connection import AWSAuthConnection

/home/dror_guldin/.local/lib/python3.5/site-packages/boto/__init__.py in ()
1214 return storage_uri(uri_str)
1215
-> 1216 boto.plugin.load_plugins(config)

AttributeError: module 'boto' has no attribute 'plugin'`

I'm also running Ubuntu16.04.

version wise:
gensim==3.2.0
smart-open==1.5.6
boto==2.48.0
boto3==1.5.19
botocore==1.8.33

@50stuck try to reinstall boto, this should help!

@menshikh-iv I tried running
pip install boto --upgrade --force-reinstall
but am still getting the same error (module 'boto' has no attribute 'plugin')

@50stuck try to google it (as I see, this is popular "boto" problem), not a gensim issue.

Was this page helpful?
0 / 5 - 0 ratings