pilat / vscode-importmagic

MIT License
36 stars 7 forks source link

Importmagic: Python interpreter is not found #19

Open taimursaeed opened 4 years ago

taimursaeed commented 4 years ago

The extension does not run and give me this error Importmagic: Python interpreter is not found

AdnanHodzic commented 4 years ago

Had same problem.

Select Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).

For the rest, I suggest you refer to: install notes

herbieliang commented 4 years ago

I get the same error, I've done "Select Python: Select Interpreter command from the command Palette (Ctrl+Shift+P)"

duilio92 commented 4 years ago

@zacharyliang be sure to set the pythonpath as well, in my case that solved the problem

jackric commented 4 years ago

I'm getting this problem too, even though I have selected an interpreter (see screenshot showing my virtualenv). The setting "python.pythonPath" is now deprecated. What's the current solution for my problem? image

defance commented 4 years ago

With the super cool experiment python.pythonPath is no longer allowed in settings.json and is removed upon each start up. So Importmagic falls back for default value which is python (without any paths, etc), and result in pointing on workspace dir.

So my current walk around is to make a soft link python in workspace, pointing the real python in virtual env.

The better solution is to fix this issue a) in configSettings.js how final python executable is resolved, or b) use PythonExecutionService instead of just ExecutionService (just like vscode launches linters).

Riad1stat commented 3 years ago

Hello, I'm getting the same problem, I've selected my virtual environment interpreter, I still get the below error:

importmagic

is there any solution to solve this issue?

jackric commented 3 years ago

@Riad1stat I moved to using Pylance https://github.com/microsoft/pylance-release which completes imports for me now. Very happy with it

mihasK commented 3 years ago

what's the status? still not fixed ?

biblicabeebli commented 3 years ago

The solution here is to set the python.pythonPath setting (you can just paste that into the settings search) to a valid python executable. I did this with a virtual python environment that has both isort and importmagic installed (I use pyenv for my venvs) and it works just fine.

However, python.pythonPath in settings states the following: (DEPRECATED: Note this setting is not used when in pythonDeprecatePythonPath experiment) Path to Python, you can use a custom version of Python by modifying this setting to include the full path.

Carsten-Leue commented 3 years ago

In case you'd like to add this to the nice import magic extension, this is how I figured you can get the python path via the "new" way:

  const pythonExtension = extensions.getExtension('ms-python.python');
  if (!pythonExtension) {
    throw new Error('Python extension not installed.');
  }
  const executable$ = pythonExtension
    .activate()
    .then((api) => api.settings)
    .then((settings) => settings.getExecutionDetails(aScope))
    .then(({ execCommand }) => execCommand[0]);

It's not 100% safe, since execCommand could be an array with more than one element, but it works for my usecases.