You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pylint not working when in pipenv virtualenv #18802
Originally posted by bmarden March 26, 2022
I think this is a bug, but I'm not sure so posting in Q&A
When I try to use pylint in a virtual environment using pipenv, pylint fails with the error below. When using my globally installed version of pylint, it works correctly.
Vscode output tab:
> ~/.local/share/virtualenvs/blog-db-loader-7J7v1WBI/bin/python ~/.vscode/extensions/ms-python.python-2022.0.1814523869/pythonFiles/linter.py -m pylint ./main.py
cwd: .
##########Linting Output - pylint##########
[ERROR 2022-2-26 19:34:41.31]: Linter 'pylint' failed to parse the output '. SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at s.parseMessages (/Users/bmarden/.vscode/extensions/ms-python.python-2022.0.1814523869/out/client/extension.js:78:360175)
at s.run (/Users/bmarden/.vscode/extensions/ms-python.python-2022.0.1814523869/out/client/extension.js:24:218086)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at s.runLinter (/Users/bmarden/.vscode/extensions/ms-python.python-2022.0.1814523869/out/client/extension.js:78:359692)
If I run the pylint command in the terminal, it works correctly
Hi Karthik Nadig (@karthiknadig), sorry about the delay on this. I ended up switching to using pyenv and the new extension you mentioned and that is working correctly.
However I did recreate the environment where it linting wasn't working and ran the command you mentioned and it doesn't look like there is a linter.py at that location
/Users/bmarden/.local/share/virtualenvs/blog-db-loader-7J7v1WBI/bin/python: can't open file '/Users/bmarden/.vscode/extensions/ms-python.python-2022.0.1814523869/pythonFiles/linter.py': [Errno 2] No such file or directory
However I copied the command that vscode is running in the output window and ran that (slightly different path to linter.py):
Traceback (most recent call last):
File "/usr/local/Cellar/python@3.10/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/Cellar/python@3.10/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/bmarden/.local/share/virtualenvs/blog-db-loader-7J7v1WBI/lib/python3.10/site-packages/pylint/__main__.py", line 9, in <module>
pylint.run_pylint()
File "/Users/bmarden/.local/share/virtualenvs/blog-db-loader-7J7v1WBI/lib/python3.10/site-packages/pylint/__init__.py", line 24, in run_pylint
PylintRun(sys.argv[1:])
File "/Users/bmarden/.local/share/virtualenvs/blog-db-loader-7J7v1WBI/lib/python3.10/site-packages/pylint/lint/run.py", line 385, in __init__
score_value = linter.generate_reports()
File "/Users/bmarden/.local/share/virtualenvs/blog-db-loader-7J7v1WBI/lib/python3.10/site-packages/pylint/lint/pylinter.py", line 1256, in generate_reports
self.reporter.display_messages(report_nodes.Section())
File "/Users/bmarden/.local/share/virtualenvs/blog-db-loader-7J7v1WBI/lib/python3.10/site-packages/pylint/reporters/json_reporter.py", line 31, in display_messages
json_dumpable = [
File "/Users/bmarden/.local/share/virtualenvs/blog-db-loader-7J7v1WBI/lib/python3.10/site-packages/pylint/reporters/json_reporter.py", line 33, in <listcomp>
"type": msg.category,
AttributeError: 'dict' object has no attribute 'category'
Hope this helps. Let me know if I can provide any further info.
Ben Marden (@bmarden) that is older version of the extension, can you update to the latest? Also, that error seems to be in pylint which is this one pylint-dev/pylint#4740. Can you confirm that you are not using pre-release version of pylint.
You are indeed correct about my pylint version. The one I had installed was the alpha release. For whatever reason pipenv installed that version by default.
Activity
karthiknadig commentedon Mar 29, 2022
Ben Marden (@bmarden) Can you run this directly in the terminal and share the output:
PS: We now have a new pylint extension. Please give it a try and see if it works in this scenario: https://marketplace.visualstudio.com/items?itemName=ms-python.pylint
bmarden commentedon Apr 5, 2022
Hi Karthik Nadig (@karthiknadig), sorry about the delay on this. I ended up switching to using pyenv and the new extension you mentioned and that is working correctly.
However I did recreate the environment where it linting wasn't working and ran the command you mentioned and it doesn't look like there is a
linter.pyat that locationHowever I copied the command that vscode is running in the output window and ran that (slightly different path to linter.py):
And the output:
Hope this helps. Let me know if I can provide any further info.
karthiknadig commentedon Apr 5, 2022
Ben Marden (@bmarden) that is older version of the extension, can you update to the latest? Also, that error seems to be in
pylintwhich is this one pylint-dev/pylint#4740. Can you confirm that you are not using pre-release version of pylint.bmarden commentedon Apr 5, 2022
You are indeed correct about my pylint version. The one I had installed was the alpha release. For whatever reason pipenv installed that version by default.
pylint --versionoutputI downgraded to
2.13.4and it solved the issue. Thanks for the help with this, and sorry about the confusion :)