Search code examples
pythonpylintconda

pylint failing in conda environment


I'm unable to get basic usage of pylint in a conda virtual environment. If this just isn't yet supported, is there another linting tool I can use?

conda install pylint
pylint testfile.py

testfile.py:

#!/usr/bin/env python
print("hello, world")

pylint path:

$ which pylint
/home/me/anaconda3/envs/myenv/bin/pylint

$ conda list | grep pylint
pylint                    1.4.2                    py35_0    defaults

Traceback:

No config file found, using default configuration
Traceback (most recent call last):
  File "/home/me/anaconda3/envs/myenv/lib/python3.5/site-packages/pylint/lint.py", line 892, in get_ast
    return MANAGER.ast_from_file(filepath, modname, source=True)
  File "/home/me/anaconda3/envs/myenv/lib/python3.5/site-packages/astroid/manager.py", line 111, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
  File "/home/me/anaconda3/envs/myenv/lib/python3.5/site-packages/astroid/builder.py", line 134, in file_build
    module = self._data_build(data, modname, path)
  File "/home/me/anaconda3/envs/myenv/lib/python3.5/site-packages/astroid/builder.py", line 177, in _data_build
    module = rebuilder.visit_module(node, modname, node_file, package)
  File "/home/me/anaconda3/envs/myenv/lib/python3.5/site-packages/astroid/rebuilder.py", line 146, in visit_module
    newnode.body = [self.visit(child, newnode) for child in node.body]
  File "/home/me/anaconda3/envs/myenv/lib/python3.5/site-packages/astroid/rebuilder.py", line 146, in <listcomp>
    newnode.body = [self.visit(child, newnode) for child in node.body]
  File "/home/me/anaconda3/envs/myenv/lib/python3.5/site-packages/astroid/rebuilder.py", line 159, in visit
    return self._transform(visit_method(node, parent))
  File "/home/me/anaconda3/envs/myenv/lib/python3.5/site-packages/astroid/rebuilder.py", line 407, in visit_discard
    newnode.value = self.visit(node.value, newnode)
  File "/home/me/anaconda3/envs/myenv/lib/python3.5/site-packages/astroid/rebuilder.py", line 159, in visit
    return self._transform(visit_method(node, parent))
  File "/home/me/anaconda3/envs/myenv/lib/python3.5/site-packages/astroid/rebuilder.py", line 311, in visit_callfunc
    if node.starargs is not None:
AttributeError: 'Call' object has no attribute 'starargs'
************* Module testfile
F:  1, 0: <class 'AttributeError'>: 'Call' object has no attribute 'starargs' (astroid-error)

https://bitbucket.org/logilab/pylint/issues/643/attributeerror-call-object-has-no


Solution

  • This problem has been fixed upstream at Bitbucket, and the code has percolated to pip, but not to Conda yet. Install it with pip for now.

    conda uninstall -y pylint
    pip install --no-input pylint
    

    [edit] The pylint package has been updated in the Continuum repository, and you can now install pylint with Conda and Python 3.5 and it works without any trouble.