3

Now I am not able to run conda or any other programme installed through conda and getting this error : "SyntaxError: invalid syntax"

I have conda installed in my computer(Ubuntu 16.04) with python 2.7 and 3.6.7 (two different virtual environments). Recently I upgraded pip to the latest version. And the the problem began. Initially I faced "Import error". I fixed it by reverting back (uninstall-reinstall) to the older version as suggested here: Error after upgrading pip: cannot import name 'main'

Now I am unable to run pip, conda or anyother programme installed through conda.

This is what I get when I call conda:

(base) mml2@ryzenpc:~$ conda
Traceback (most recent call last):
  File "/home/mml2/miniconda2/bin/conda", line 12, in <module>
    from conda.cli import main
  File "/home/mml2/miniconda2/lib/python3.6/site-packages/conda/__init__.py", line 19, in <module>
    from .common.compat import text_type, iteritems
  File "/home/mml2/miniconda2/lib/python3.6/site-packages/conda/common/compat.py", line 87, in <module>
    from json import JSONDecodeError
  File "/home/mml2/miniconda2/lib/python3.6/json/__init__.py", line 106, in <module>
    from .decoder import JSONDecoder, JSONDecodeError
  File "/home/mml2/miniconda2/lib/python3.6/json/decoder.py", line 3, in <module>
    import re
  File "/home/mml2/miniconda2/lib/python3.6/re.py", line 122, in <module>
    import enum
  File "/home/mml2/Libs/LibsDyogen/enum.py", line 66
    raise NotImplementedError, \
                             ^
SyntaxError: invalid syntax
(base) mml2@ryzenpc:~$ 

Can anyone help me to solve this issue? Please let me know if you need any other details regarding this problem.

phd
  • 82,685
  • 13
  • 120
  • 165
KG_SOf
  • 41
  • 1
  • 3
  • 1
    `raise Error, message` is a syntax error in Python 3. You're running Python 2 code in Python 3. I think you should remove your Python 3.6 environment and recreate it anew. – phd Jun 25 '19 at 10:43

2 Answers2

1

It looks like you are trying to import a python2 library on python3. To avoid confusion with pip, pip2, pip3 etc, just try installing using pip as a method specifying the python interpreter. python3 -m pip install the_lib_you_need

alec_djinn
  • 10,104
  • 8
  • 46
  • 71
1

I figured out the solution. Apparently, my $PYTHONPATH variable was pointing to a directory, as it was required for running a particular programme. Now after deleting that line from my .bashrc conda and other programmes are running fine.

KG_SOf
  • 41
  • 1
  • 3