vscode-importmagic
vscode-importmagic copied to clipboard
Importmagic: Python interpreter is not found
The extension does not run and give me this error Importmagic: Python interpreter is not found
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
I get the same error, I've done "Select Python: Select Interpreter command from the command Palette (Ctrl+Shift+P)"
@zacharyliang be sure to set the pythonpath as well, in my case that solved the problem
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?
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).
Hello, I'm getting the same problem, I've selected my virtual environment interpreter, I still get the below error:
is there any solution to solve this issue?
@Riad1stat I moved to using Pylance https://github.com/microsoft/pylance-release which completes imports for me now. Very happy with it
what's the status? still not fixed ?
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.
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.