简体   繁体   English

调用帮助功能时repr.py中的Python语法错误

[英]Python syntax error in repr.py when calling help function

I am having a very odd problem with Python. 我在使用Python时遇到了一个非常奇怪的问题。 Whenever I try to use the built-in help function, I get this error: 每当我尝试使用内置帮助功能时,都会出现此错误:

    Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site.py", line 468, in __call__
    import pydoc
  File "/usr/lib/python2.7/pydoc.py", line 56, in <module>
    from repr import Repr
  File "repr.py", line 21
    def 
       ^
SyntaxError: invalid syntax

I have manually inspected the aforementioned files, but I don't see the error mentioned. 我已经手动检查了上述文件,但没有看到提到的错误。 I also tried deleting the .pyc files for the files mentioned in the trceback in the /usr/share/python2.7 directory, but I am still having the issue. 我也尝试删除/usr/share/python2.7目录中trceback中提到的文件的.pyc文件,但是仍然存在问题。

My computer is running Ubuntu 12.10 64 bit. 我的计算机运行的是Ubuntu 12.10 64位。

Do you have a file called repr.py in the current directory? 当前目录中是否有一个名为repr.py的文件? That file is incomplete, and shadows the standard library repr module. 该文件不完整,并且遮盖了标准库repr模块。 You can see from the traceback that the file has no full path, only a local path. 从回溯中可以看到文件没有完整路径,只有本地路径。 Rename it or remove it. 重命名或删除它。

Please, do not just delete .pyc files from your system folders, please reinstall python from packages (using your package manager). 请不要只是从系统文件夹中删除.pyc文件,请从软件包中重新安装python(使用软件包管理器)。

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

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