Pergunta

When trying to install gensim (with pip install and setup install), it gives me this error:

Traceback (most recent call last):
  File "setup.py", line 19, in <module>
    import ez_setup
  File "C:\Users\User\Desktop\gensim-0.8.7\ez_setup.py", line 106
    except pkg_resources.VersionConflict, e:
                                        ^
SyntaxError: invalid syntax

How can I solve this

Foi útil?

Solução

I've never worked in Gensim, but I'm pretty sure the problem is that you have incompatible versions of it and Python. The below code uses Python 2.x. syntax.

except pkg_resources.VersionConflict, e:

In Python 3.x. however, you use as instead of ,:

except pkg_resources.VersionConflict as e:

Below is a demonstration written in Python 3.x.:

>>> try:
...     1/0
... except ZeroDivisionError, e:
  File "<stdin>", line 3
    except ZeroDivisionError, e:
                            ^
SyntaxError: invalid syntax
>>>
>>> try:
...     1/0
... except ZeroDivisionError as e:
...     print(e)
...
division by zero
>>>

As you can see, it is your exact same error.

So, to fix the problem, you need to fix the versions. Either set Python to version 2.x. or get a version of Gensim that runs with Python 3.x.


I'm going to move the comment into my post because it is important. Here is the link to Gensim for Python 3.x.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top