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

Plugin can't find python interpreter when there are multiple SDKs defined #31

Open cpchen opened 5 years ago

cpchen 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. On IntelliJ, make two SDKs (one Java and one Python)
  2. Try running Pylint

Observed Results:

Expected Results:

idea.log

cpchen commented 5 years ago

Continuing discussion from https://github.com/leinardi/pylint-pycharm/issues/7#issuecomment-429242023

cpchen commented 5 years ago

i think the configuration that points to the interpreter is in File > Project Structure > Project Settings > Project like here:

image

cpchen commented 5 years ago

here is where the dual sdks are defined

image

cpchen commented 5 years ago

thanks for the prompt responses by the way!

vlasovskikh commented 5 years ago

@leinardi (continuing the thread in #7) You can get a VirtualFile from String via LocalFileSystem.getInstance().findFileByIoFile(), see the docs. There are useful docs on the project / modules structure (each can have an SDK) and the layered view of files (VirtualFile / Document / PsiFile). I highly recommend The IntelliJ Architectural Overview, especial Part 2 Base Platform and Part 3 Project Model.

cpchen commented 5 years ago

Any update on this?

leinardi commented 5 years ago

Hi @cpchen, unfortunately I don't have any update on this issue because I still need to find a way to get the Python interpreter without the need of a Python file: the plugin should be able to run PyLint without the need of a Python file to check if everything is set up correctly.

What I would like to have is a list of all the interpreters available and let the user choose which one he want to use inside the plugin Settings. But I still don't know how to get this list.

BengtOFFIS commented 5 years ago

I am not sure if I get where exactly the issue is. However, PyCharm already has a way to select the project interpreter. Could pylint-pycharm just use the interpreter configured by the user for the current project? If the interpreter could not be found, PyCharm will also already warn the user. So, there are interpreter-level checks in place. Your checks in isPylintPathValid also verify that PyLint can be found and is working. An easier way to make sure would be to pip install --upgrade pylint, so that the Event Log can notify the user if there were any issues. PyCharm already works that way with installing Python's packaging tools into new virtual environments.

leinardi commented 5 years ago

Hi @BengtOFFIS, afaik this issue only happens on Intellij IDEA when you have more than one interpreter (eg Java JDK and Python).

BengtOFFIS commented 5 years ago

Hi @leinardi, thanks for the swift reply. I also get an error in PyCharm, where I have multiple interpreters configured for multiple projects:

17:01   Pylint Plugin
    No Python interpreter configured for the project.
    Configure Python interpreter
BengtOFFIS commented 5 years ago

That error occurs whenever I scan the current file, module or project with the automatically detected system pylint in C:\Python27\Scripts\ or with the interpreter pylint in .tox\py37\Scripts\ under Windows.

BengtOFFIS commented 5 years ago

The error in my idea.log at least seems similar to what @cpchen is seeing, if you search for "harm.pylint.plapi.PylintRunner - Error":

idea.log

Also I noticed that it does not make a difference whether or not I set the pylint path to the virtual environment or not, I always see "No config file found, using default configuration".

leinardi commented 5 years ago

Mmm I see, I did not take in consideration the possibility of having multiple interpreters when I developed the plugin. Adding support for it now is going to require quite some effort and I fear I don't have the time currently.

I think that, to properly handle it, I should follow the suggestion from @vlasovskikh and get the interpreter directly from the file. This means build a separate list of files to scan for each interpreter and starting multiple PyLint process for each list.

I might find some time at the end of next month or start of next year to look at this. But PR are welcome (if someone want to work on this, before start the coding let's have a talk and agree on a shared solution).

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.

fjmacagno commented 1 year ago

It looks like this is still a problem?