vscode-importmagic icon indicating copy to clipboard operation
vscode-importmagic copied to clipboard

Importmagic: Python interpreter is not found

Open taimursaeed opened this issue 5 years ago • 10 comments

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

taimursaeed avatar Nov 15 '19 11:11 taimursaeed

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

AdnanHodzic avatar Dec 08 '19 13:12 AdnanHodzic

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

herbieliang avatar May 28 '20 07:05 herbieliang

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

duilio92 avatar Jun 17 '20 17:06 duilio92

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

jackric avatar Jul 27 '20 09:07 jackric

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).

defance avatar Oct 06 '20 15:10 defance

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?

Riad1stat avatar Dec 02 '20 11:12 Riad1stat

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

jackric avatar Dec 02 '20 11:12 jackric

what's the status? still not fixed ?

mihasK avatar Jun 29 '21 18:06 mihasK

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.

biblicabeebli avatar Jul 14 '21 23:07 biblicabeebli

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.

Carsten-Leue avatar Sep 06 '21 15:09 Carsten-Leue