简体   繁体   English

SyntaxError:conda中的语法无效

[英]SyntaxError: invalid syntax in conda

Now I am not able to run conda or any other programme installed through conda and getting this error : "SyntaxError: invalid syntax" 现在,我无法运行conda或通过conda安装的任何其他程序,并出现以下错误:“ SyntaxError:无效语法”

I have conda installed in my computer(Ubuntu 16.04) with python 2.7 and 3.6.7 (two different virtual environments). 我在计算机(Ubuntu 16.04)中安装了python 2.7和3.6.7(两个不同的虚拟环境)的conda。 Recently I upgraded pip to the latest version. 最近,我将pip升级到了最新版本。 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' 我通过按以下建议将其还原(卸载-重新安装)为旧版本来修复它: 升级pip后出错:无法导入名称“ main”

Now I am unable to run pip, conda or anyother programme installed through conda. 现在,我无法运行通过conda安装的pip,conda或任何其他程序。

This is what I get when I call conda: 这是我打电话给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. 如果您需要有关此问题的任何其他详细信息,请告诉我。

It looks like you are trying to import a python2 library on python3. 看来您正在尝试在python3上导入python2库。 To avoid confusion with pip, pip2, pip3 etc, just try installing using pip as a method specifying the python interpreter. 为了避免与pip,pip2,pip3等混淆,只需尝试使用pip作为指定python解释器的方法进行安装。 python3 -m pip install the_lib_you_need

I figured out the solution. 我想出了解决方案。 Apparently, my $PYTHONPATH variable was pointing to a directory, as it was required for running a particular programme. 显然,我的$ PYTHONPATH变量指向目录,这是运行特定程序所必需的。 Now after deleting that line from my .bashrc conda and other programmes are running fine. 现在,从我的.bashrc conda中删除该行之后,其他程序运行正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM