Skip to main content
 首页 » 编程设计

python之Pylint 属性错误 : 'module' object has no attribute 'append'

2025年04月02日34tuyile006

我正在配置我的新笔记本电脑 (macbook pro),一切都很好,直到我想尝试我的 pylint 命令。

Traceback (most recent call last): 
  File "/usr/local/bin/pylint", line 11, in <module> 
    load_entry_point('pylint==1.6.4', 'console_scripts', 'pylint')() 
  File "/usr/local/lib/python2.7/site-packages/pylint-1.6.4-py2.7.egg/pylint/__init__.py", line 13, in run_pylint 
    Run(sys.argv[1:]) 
  File "/usr/local/lib/python2.7/site-packages/pylint-1.6.4-py2.7.egg/pylint/lint.py", line 1270, in __init__ 
    'init-hook'))) 
  File "/usr/local/lib/python2.7/site-packages/pylint-1.6.4-py2.7.egg/pylint/lint.py", line 1371, in cb_init_hook 
    exec(value) # pylint: disable=exec-used 
  File "<string>", line 1, in <module> 
AttributeError: 'module' object has no attribute 'append' 

从那以后,我不明白我的 pylint 出了什么问题......我尝试了很多事情,但由于我不太确定我最后做了什么,所以我宁愿不列出事情。

有人已经拿到了吗?有人知道如何解决吗?

谢谢你的帮助

请您参考如下方法:

Hi, can you show the value of init-hook from the configuration file you are using? What happen is that you have configured, somehow, init-hook with some invalid code. You can see this in your traceback through the last exec call, which happens only when init-hook is provided. Seeing its value could lead to solving this problem. My intuition is that you probably have something as in ``init-hook="import sys; sys.append(some_path)"

感谢PCManticore ,就是这样,我的主文件夹中有一个 .pylintrc,其中包含 init-hook 值的内容。我更改了它,现在一切正常。