无法在ubuntu上使用Python 3.5安装Gensim

时间:2019-09-05 11:32:05

标签: python docker ubuntu gensim

我正在ubuntu基本映像上运行dockerfile,如下所示:

FROM ubuntu:14.04

# Install dependencies
RUN apt-get update 
RUN apt-get install -y \
    software-properties-common
RUN add-apt-repository universe
RUN apt-get install -y python3.5 \
    python3-pip 

RUN apt-get install libav-tools -y

RUN apt-get update 

RUN apt-get upgrade

#RUN  apt-get install google-cloud-sdk

RUN pip3 install --upgrade pip 
RUN pip3 install pandas 
RUN pip3 install glob3

RUN     pip3 install --upgrade pip 
#RUN    pip3 install pandas 
RUN pip3 install glob3
#RUN    pip3 install json
RUN pip3 install numpy
RUN pip3 install fuzzywuzzy
RUN pip3 install gensim

我在这台计算机上安装了python 3.5,但是仍然出现如下错误:

Collecting gensim
  Downloading https://files.pythonhosted.org/packages/3a/bc/1415be59292a23ff123298b4b46ec4be80b3bfe72c8d188b58ab2653dee4/gensim-3.8.0.tar.gz (23.4MB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-klg_2vmh/gensim/setup.py'"'"'; __file__='"'"'/tmp/pip-install-klg_2vmh/gensim/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /tmp/pip-install-klg_2vmh/gensim/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-klg_2vmh/gensim/setup.py", line 23, in <module>
        raise Exception('This version of gensim needs Python 2.7, 3.5 or later.')
    Exception: This version of gensim needs Python 2.7, 3.5 or later.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

我是否需要下载某些特定版本的Gensim,或者这是一些不同的错误。

1 个答案:

答案 0 :(得分:0)

使用python:3.5

FROM python:3.5
RUN pip install gensim glob3 ....

这将为您节省很多空间和步骤。。

如果您仍要使用ubuntu:14.04,则需要使用以下内容:

apt-get install -y python-dev && python3.5 -m pip install gensim

因为python3.4image的默认设置