Gensim安装问题

8

我正在尝试在Google Cloud实例上安装gensim,使用以下命令:

pip3 install gensim

当我尝试导入gensim时,出现了以下错误信息:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/gensim/__init__.py", line 6, in <module>
    from gensim import parsing, matutils, interfaces, corpora, models, similarities, summarization
  File "/usr/local/lib/python3.4/dist-packages/gensim/models/__init__.py", line 7, in <module>
    from .coherencemodel import CoherenceModel
  File "/usr/local/lib/python3.4/dist-packages/gensim/models/coherencemodel.py", line 30, in <module>
    from gensim.models.wrappers import LdaVowpalWabbit, LdaMallet
  File "/usr/local/lib/python3.4/dist-packages/gensim/models/wrappers/__init__.py", line 5, in <module>
    from .ldamallet import LdaMallet
  File "/usr/local/lib/python3.4/dist-packages/gensim/models/wrappers/ldamallet.py", line 43, in <module>
    from smart_open import smart_open
  File "/usr/local/lib/python3.4/dist-packages/smart_open/__init__.py", line 1, in <module>
    from .smart_open_lib import *
  File "/usr/local/lib/python3.4/dist-packages/smart_open/smart_open_lib.py", line 36, in <module>
    import boto.s3.key
  File "/usr/local/lib/python3.4/dist-packages/boto/s3/key.py", line 33, in <module>
    import boto.utils
  File "/usr/local/lib/python3.4/dist-packages/boto/__init__.py", line 1216, in <module>
    boto.plugin.load_plugins(config)
AttributeError: 'module' object has no attribute 'plugin'

这是 Linux 版本(lsb_release -a 的输出):
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 8.6 (jessie)
Release:    8.6
Codename:   jessie

这是执行

pip3 freeze

命令的输出结果:

Cython==0.25.1
Flask==0.11.1
Jinja2==2.8
MarkupSafe==0.23
Pillow==2.6.1
Werkzeug==0.11.11
beautifulsoup4==4.3.2
boto==2.43.0
bz2file==0.98
chardet==2.3.0
click==6.6
colorama==0.3.2
decorator==3.4.0
gensim==0.13.3
html5lib==0.999
itsdangerous==0.24
lxml==3.4.0
matplotlib==1.4.2
nltk==3.2.1
nose==1.3.4
numexpr==2.4
numpy==1.11.2
pandas==0.14.1
pyparsing==2.0.3
python-apt==0.9.3.12
python-dateutil==2.2
pytz==2012c
requests==2.4.3
scipy==0.14.0
six==1.8.0
smart-open==1.3.5
stop-words==2015.2.23.1
tables==3.1.1
unattended-upgrades==0.1
urllib3==1.9.1
wheel==0.24.0

有人能给我指点吗!这非常令人沮丧。


1
你尝试过使用 "sudo easy_install -U gensim" 进行安装吗?对我来说,pip从来都不起作用,但这种方法可以解决问题。 - Salvador Medina
我在pip3卸载后尝试了"easy-install-3.4 gensim",但是仍然出现相同的错误! - VJune
3个回答

19

2

修复方法:

sudo pip3 uninstall boto

sudo pip3 install boto

看起来是与Google计算云有关。


1
卸载boto时出现错误。无法卸载“boto”。它是一个distutils安装的项目,因此我们无法准确确定哪些文件属于它,这将导致只能部分卸载。 - Pramod Patil

0
这个问题主要是由于boto插件或配置文件中存在垃圾所致。 因此,正如@vJune建议的那样,我们需要卸载boto库,然后重新安装。 我只需删除python-boto软件包就解决了这个问题。
在Google Compute Engine上: 步骤1:卸载python-boto软件包。
sudo apt-get remove python-boto

步骤2:安装python-boto库

sudo apt-get install python-boto

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接