leinardi / pylint-pycharm

A plugin providing both real-time and on-demand scanning of Python files with PyLint from within PyCharm/IDEA.
Apache License 2.0
197 stars 35 forks source link

Error while checking Pylint path #35

Open chilicheech opened 5 years ago

chilicheech commented 5 years ago

Step 1: Are you in the right place?

Step 2: Describe your environment

Step 3: Describe the problem:

Steps to reproduce:

  1. Install pyenv, pyenv-virtualenv, and python 2.7.15
  2. Create a virtualenv with pyenv virtualenv 2.7.15 venvname
  3. pip install pylint==1.5.5
  4. Open IDEA, create a python project using the above venvname as the python sdk
  5. Close IDEA, reopen it
  6. Error is thrown

Observed Results:

Expected Results:

Relevant Code:

No code to report

java.lang.Throwable: Error while checking Pylint path:   File "/Users/thiago.oliveira/.pyenv/shims/pylint", line 3
    [ -n "$PYENV_DEBUG" ] && set -x
                      ^
SyntaxError: invalid syntax
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:134)
    at com.leinardi.pycharm.pylint.plapi.PylintRunner.isPylintPathValid(PylintRunner.java:98)
    at com.leinardi.pycharm.pylint.ui.PylintConfigPanel$TestAction.actionPerformed(PylintConfigPanel.java:115)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6548)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3325)
    at java.awt.Component.processEvent(Component.java:6313)
    at java.awt.Container.processEvent(Container.java:2237)
    at java.awt.Component.dispatchEventImpl(Component.java:4903)
    at java.awt.Container.dispatchEventImpl(Container.java:2295)
    at java.awt.Component.dispatchEvent(Component.java:4725)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4889)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4526)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4467)
    at java.awt.Container.dispatchEventImpl(Container.java:2281)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4725)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
    at java.awt.EventQueue.access$500(EventQueue.java:98)
    at java.awt.EventQueue$3.run(EventQueue.java:715)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:737)
    at java.awt.EventQueue$4.run(EventQueue.java:735)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:719)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:664)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:363)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:109)
    at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:190)
    at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:235)
    at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:233)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:233)
    at java.awt.Dialog.show(Dialog.java:1077)
    at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:698)
    at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:430)
    at com.intellij.openapi.ui.DialogWrapper.invokeShow(DialogWrapper.java:1681)
    at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1630)
    at com.intellij.openapi.options.newEditor.SettingsDialog.lambda$show$0(SettingsDialog.java:70)
    at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
    at com.intellij.openapi.application.TransactionGuardImpl.submitTransactionAndWait(TransactionGuardImpl.java:153)
    at com.intellij.openapi.options.newEditor.SettingsDialog.show(SettingsDialog.java:70)
    at com.intellij.ide.actions.ShowSettingsUtilImpl.showSettingsDialog(ShowSettingsUtilImpl.java:84)
    at com.intellij.ide.actions.ShowSettingsAction.perform(ShowSettingsAction.java:50)
    at com.intellij.ide.MacOSApplicationProvider$Worker.lambda$null$1(MacOSApplicationProvider.java:104)
    at com.intellij.ide.MacOSApplicationProvider$Worker.lambda$submit$7(MacOSApplicationProvider.java:179)
    at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
    at com.intellij.openapi.application.TransactionGuardImpl.lambda$pollQueueLater$0(TransactionGuardImpl.java:74)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:435)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:419)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:403)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
    at java.awt.EventQueue.access$500(EventQueue.java:98)
    at java.awt.EventQueue$3.run(EventQueue.java:715)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:719)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:668)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:363)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
chsergey commented 5 years ago

I have same problem

PyCharm 2017.3.4 (Professional Edition) Build #PY-173.4674.37, built on March 6, 2018 JRE: 1.8.0_152-release-1024-b15 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Windows 7 6.1

Error while checking Pylint path: No config file found, using default configuration java.lang.Throwable: Error while checking Pylint path: No config file found, using default configuration at com.intellij.openapi.diagnostic.Logger.error(Logger.java:136) at com.leinardi.pycharm.pylint.plapi.PylintRunner.isPylintPathValid(PylintRunner.java:98) at com.leinardi.pycharm.pylint.plapi.PylintRunner.checkPylintAvailable(PylintRunner.java:176) at com.leinardi.pycharm.pylint.plapi.PylintRunner.checkPylintAvailable(PylintRunner.java:150) at com.leinardi.pycharm.pylint.PylintInspection.inspectFile(PylintInspection.java:76) at com.leinardi.pycharm.pylint.PylintInspection.lambda$checkFile$0(PylintInspection.java:65) at com.intellij.openapi.application.impl.ApplicationImpl$2.call(ApplicationImpl.java:338) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

but I already configured option "Path to pylintrc"

And plugin also start checking in SQL console too after CTRL+S.

dazza-codes commented 5 years ago

I'll have to disable the plugin due to this failure to find pylint (using all the default plugin settings, no explicit override for the pylint path). Even with an explict override for the pylint path, the plugin still issues errors about a failure to find it.

Step 2: Describe your environment

$ which pylint /home/{snipped}/.local/share/virtualenvs/py_package_template-AfLMl-fG/bin/pylint

$ pylint --version pylint 2.1.1 astroid 2.0.4 Python 3.7.0 (default, Jun 28 2018, 13:15:42) [GCC 7.2.0]


- PyCharm version: 2018.3.2

PyCharm 2018.3.2 (Professional Edition) Build #PY-183.4886.43, built on December 18, 2018 JRE: 1.8.0_152-release-1343-b26 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Linux 4.15.0-43-generic


The stacktrace is:

java.lang.Throwable: Pylint path detect process.exitValue: 1 at com.intellij.openapi.diagnostic.Logger.error(Logger.java:134) at com.leinardi.pycharm.pylint.plapi.PylintRunner.detectSystemPylintPath(PylintRunner.java:218) at com.leinardi.pycharm.pylint.plapi.PylintRunner.getPylintPath(PylintRunner.java:144) at com.leinardi.pycharm.pylint.plapi.PylintRunner.getPylintPath(PylintRunner.java:120) at com.leinardi.pycharm.pylint.plapi.PylintRunner.checkPylintAvailable(PylintRunner.java:176) at com.leinardi.pycharm.pylint.plapi.PylintRunner.checkPylintAvailable(PylintRunner.java:150) at com.leinardi.pycharm.pylint.PylintInspection.inspectFile(PylintInspection.java:76) at com.leinardi.pycharm.pylint.PylintInspection.lambda$checkFile$0(PylintInspection.java:65) at com.intellij.openapi.application.impl.ApplicationImpl$2.call(ApplicationImpl.java:337) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

chilicheech commented 5 years ago

I get the same error with these versions:

pylint 1.9.4,
astroid 1.6.5
Python 2.7.15 (default, Dec 18 2018, 14:05:33)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.10.44.4)]
pyenv 1.2.8

Because I'm using pyenv with pyenv-virtualenv it creates a shim for pylint so that it points to the correct one for that virtualenv: /Users/thiago.oliveira/.pyenv/shims/pylint. The contents of this file are:

#!/usr/bin/env bash
set -e
[ -n "$PYENV_DEBUG" ] && set -x

program="${0##*/}"
if [[ "$program" = "python"* ]]; then
  for arg; do
    case "$arg" in
    -c* | -- ) break ;;
    */* )
      if [ -f "$arg" ]; then
        export PYENV_FILE_ARG="$arg"
        break
      fi
      ;;
    esac
  done
fi

export PYENV_ROOT="/Users/thiago.oliveira/.pyenv"
exec "/usr/local/Cellar/pyenv/1.2.8_1/libexec/pyenv" exec "$program" "$@"

Not sure why it thinks this is invalid syntax: [ -n "$PYENV_DEBUG" ]. It's perfectly valid bash syntax.

When I point it to the actual file /Users/thiago.oliveira/.pyenv/versions/2.7.15/bin/pylint it works fine. Here's the contents of the actual file:

#!/Users/thiago.oliveira/.pyenv/versions/2.7.15/bin/python

# -*- coding: utf-8 -*-
import re
import sys

from pylint import run_pylint

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(run_pylint())

Please add support for pyenv-virtualenv if it isn't yet supported.

borice commented 5 years ago

I have the same issue on OSX Mojave with IDEA 2018.3. Details below:

> pylint --version
pylint 2.2.2
astroid 2.1.0
Python 3.6.8 |Anaconda, Inc.| (default, Dec 29 2018, 19:04:46)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
java.lang.Throwable: Pylint path detect process.exitValue: 1
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:134)
    at com.leinardi.pycharm.pylint.plapi.PylintRunner.detectSystemPylintPath(PylintRunner.java:218)
    at com.leinardi.pycharm.pylint.plapi.PylintRunner.getPylintPath(PylintRunner.java:144)
    at com.leinardi.pycharm.pylint.plapi.PylintRunner.getPylintPath(PylintRunner.java:120)
    at com.leinardi.pycharm.pylint.plapi.PylintRunner.checkPylintAvailable(PylintRunner.java:176)
    at com.leinardi.pycharm.pylint.plapi.PylintRunner.checkPylintAvailable(PylintRunner.java:150)
    at com.leinardi.pycharm.pylint.PylintInspection.inspectFile(PylintInspection.java:76)
    at com.leinardi.pycharm.pylint.PylintInspection.lambda$checkFile$0(PylintInspection.java:65)
    at com.intellij.openapi.application.impl.ApplicationImpl$2.call(ApplicationImpl.java:337)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

This happens when I'm working on a non-Python project (like Java, Scala, whatever) and I don't manually configure the pylint path in the "Other Settings -> Pylint" section. If I work on a Python project and set the path to Pylint then the error doesn't show up.

Even if I try setting the Pylint path when working on a non-Python project, when I click the "Test" button, a red X is displayed indicating that the test didn't succeed. When looking at the idea.log file, the following error is recorded:

INFO - harm.pylint.plapi.PylintRunner - Command Line string: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home /Applications/Development/anaconda3/bin/pylint --help-msg E1101 ile checking Pylint path
com.intellij.execution.process.ProcessNotCreatedException: Cannot run program "/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home": error=13, Permission deniedon.configurations.GeneralCommandLine.createProcess(GeneralCommandLine.java:416)
        at com.leinardi.pycharm.pylint.plapi.PylintRunner.isPylintPathValid(PylintRunner.java:92)
        at com.leinardi.pycharm.pylint.ui.PylintConfigPanel$TestAction.actionPerformed(PylintConfigPanel.java:115)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
        ....

It seems the plugin is trying to run pylint using the current project's SDK which, for a Java project (for example) would be the JDK. Obviously that won't work. I think this happens here: https://github.com/leinardi/pylint-pycharm/blob/4af2fe58d7edc3c3d187d538b6bd4308493f32f7/src/main/java/com/leinardi/pycharm/pylint/plapi/PylintRunner.java#L318

Perhaps this plugin should skip the detection of pylint for non-Python projects (if possible).

Thanks for the plugin!

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had activity in the last 60 days.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had activity in the last 60 days.

chilicheech commented 3 years ago

I'm no longer seeing the original issue that was reported. But I'm seeing the issue @borice mentioned.