I had the exact same issues above, «Command ‘Python: Select Interpreter’ resulted in an error (command ‘python.setInterpreter’ not found)»
RHEL 7.9
vs-code: 1.52.1(Downgraded from 1.54.3 due to incompatible changes in library dependencies)
python: 3.6.8
Initially, when I tried to run my python files, I would get an error that jupyter notebook could not be loaded. When I finally went to set the interpreter using Shift-ctl-P , I got "Command 'Python: Select Interpreter' resulted in an error (command 'python.setInterpreter' not found)"
Solved it by deleting .vscode in my home directory. I’m guessing this would be %USERPROFILE%.vscode in windows. Relaunching vscode recreated the .vscode directory and then it prompted me to download all the extensions I needed. Not sure if it helps, but I think this may fix most of the problems above.
I have been using VSCode for a while and so far everything was good. Yesterday I created a new django project with it’s own virtual environment. However, something happened to VSCode that it cannot find any interpreters. When I click shift+command+P and type >python: select interpreter, it gives me an error. I can still run my code and it works, which is weird but it is very uncomfortable to work like that because the colors are not highlighted in the code.
asked Oct 18, 2021 at 16:29
1
I ran into this problem with my newly installed VSCode on my Win10,and I fixed it by referring to other people’s blog. The solution is somewhat complicated as follows:
First find the location where Microsoft VS Code is installed, then create a test folder in the same level directory, open this folder with VSCode, create a new VSCode window and open the folder where your python files are located, then select python interpreter.
answered Jun 8, 2022 at 10:50
zerozero
212 bronze badges
I also faced the same issue and was able to solve it by doing the following:
I tried reverting to an older version of the python extension to see if that would fix the problem and it fixed the problem.
To install older version of python extension on VScode: Go to Extensions(Ctrl+Shift+X) then right click on the python extension, click on Install Another Version and choose an older version.
I hope this helps others who are facing the same issue!
answered Dec 8, 2022 at 14:13
I created file .ipynb and open it with VS Code. I had the same error.
Then I created folder and put this file to folder. After that, I opened folder with VS Code and try command Python: Select interpreter
again. And it works. I was able to choose version of interpreter.
I hope this will be useful to you.
answered Mar 21 at 18:32
@karthiknadig There is nothing in the Output > Python panel if I am looking in the correct location. I assume you mean the Output that can be reached by View -> Output. I also don’t see anything in View -> Problems (It simply says «No problems have been detected in the workspace»). In the Help -> Toggle Developer tools I do see some errors and warnings. Interestingly, I see errors with v2020.10.332292344 (which eventually works) and v2021.2.636928669 (which doesn’t work). In both cases, after opening vscode and it begins to load a python project, I get a warning in the bottom right of the workspace:
IntelliCode Python support requires you to use the Microsoft Python Language Server (preview)
When I click on the button: Enable it and Reload Window, the v2020.10 version loads the python interpreter and the v2020.2 never does.
Looking at the error log in the Developer Tools in v2020.2 (after enabling the Microsoft Python Language Server) I see the following errors:
IntelliCode Python support requires you to use the Microsoft Python Language Server (preview). onDidChangeNotification @ notificationsAlerts.ts:40
Cannot activate extension 'Python' because it depends on extension 'ms-toolsai.jupyter', which failed to activate. _logMessageInConsole @ abstractExtensionService.ts:718
Activating extension 'ms-toolsai.jupyter' failed: Unable to write into user settings. Please open the user settings to correct errors/warnings in it and try again.. _logMessageInConsole @ abstractExtensionService.ts:718
[Extension Host] (node:81920) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. v @ console.ts:137
In addition to the errors there are 5 warnings 4 of which seem to be related to the same issue
[Extension Host] stack trace: Error: Unable to write into user settings. Please open the user settings to correct errors/warnings in it and try again. at w.reject (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2013:16717) at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2013:20787 at async w.doWriteConfiguration (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:2013:13896) v @ console.ts:137
So I am wondering why the Extension Host is not able to write to the user settings. Maybe that is the root cause, which produces the errors?
Thoughts? Next steps?
Я впервые устанавливаю Python 3.7.2 и использую расширение Python VS Code.
Когда я бегу python -V я получаю Python 2.7.10 что не правильно!
Когда я выбираю интерпретатор usr/local/bin/python3 в VS Code, я получаю эту ошибку при запуске скрипта:
bash: /Users/erik/Work/Python/usr/local/bin/python3: No such file or directory
Но когда я смотрю usr/local/bin , я вижу, что там есть Python3. Я не уверен, почему VS Code вставляет рабочий каталог перед usr/local/bin ?
Моя первая мысль заключалась в том, что Python3 должен быть в переменной PATH, поэтому я запустил включенную команду Update Shell Profile , которая дает следующую обратную связь:
Теперь, после перезагрузки VS Code, я получаю новую опцию выбора интерпретатора:
Это отличается от Python в usr/local/bin ? Когда я выбираю его, я получаю эту ошибку:
The script isort is installed in ‘/Users/erik/Library/Python/3.7/bin’ which is not on PATH.
Я также получаю эту боковую ошибку:
You are using pip version 18.1. You should consider upgrading via the ‘pip install —upgrade pip’ command.
Но, следуя этим инструкциям, я получаю еще одну ошибку:
В целом, этот процесс и официальная документация кажутся менее удобными для пользователя? По-видимому, мне нужно глубоко покопаться в системных файлах моего Mac в терминале, прежде чем даже написать одну строку кода.
Я пропустил важный шаг здесь?
Как вы установили Python (из Python.org? Вы собрали его из исходного кода? Или используете версию, поставляемую с вашей ОС)? Вы пытались установить путь Python вручную, добавив «python.pythonPath»: «/usr/local/bin/python3» к settings.json ? Если это не сработает, используйте путь, который выводит which python3 , и добавьте его.
Вы можете попробовать открыть свой .bashrc и добавить путь, который, как он говорит, отсутствует. Что касается pip, вы, вероятно, можете заставить его работать с pip2 или pip3.
Как ты запускал питон? Попробуйте щелкнуть правой кнопкой мыши, когда курсор находится над окном редактора, выберите «запустить файл Python в терминале».
@Joey Джоуи, вот откуда внезапно появился путь Library/Frameworks/ в VS Code! (по-видимому, VS Code автоматически нашел этот путь). НО, правильно ли это? Так не должно быть usr/local/bin/ .
@bashrc хм, у меня есть идея, что я добавляю пути по всей своей системе. Есть файл .bash, файл .profile, файл .bash_profile, а теперь файл .bashrc? Что я должен использовать?
Vs code не видит скачанные библиотеки в python
писал раньше код в pycharm , он сразу видел какие библиотеки установлены и сразу помогал дописывать атрибуты и т.д. а vs code не видит скачанные библиотеки как это исправить?
Первое и важное необходимо установить расширение для python. Данное расширение поддерживает заполнение для кода и функцию IntelliSense . IntelliSense — это общий термин для ряда функций, которые и дают подсказки в коде для всех ваших файлов как built-in , так и для сторонних модулей. IntelliSense отображает переменные, методы, объекты классов и документацию в момент ввода. Более подробную информацию можно подчерпнуть на официальной страничке посвещенной данному вопросу.
Поскольку всегда, а правильнее сказать, как правило используются виртуальные пространства, то и модули для будут отличаться от глобальных установок. В этом случае в VSCode предусмотрено переключение на тот интерпретатор, который необходим в данном рабочем процессе.
Приведу пример. При помощи python -m venv env команды я создам виртуальное пространство для проекта, которое будет включать нужную версию python и модули, которые нужны только для данного проекта. Если не конфигурировался проект изначально при запуске VSCode будет цеплять глобальный python и глобальные модули (возможно, в новых версиях это не так). Это можно увидеть в нижнем левом углу интерфейса VSCode
При нажатии на данную область появится меню вверху окна с возможностью выбора пространства
Где я и могу выбрать нужный мне python 3.8.6 64-bit (‘env’:venv) . Из данного примера можно увидеть, что я могу использовать разные версии python и соответственно модули, для которых и будет работать IntelliSense .
Pip and Python in Visual Studio Code
I’m not a Python expert, but I used it more often these days and I use Visual Studio Code with Python extension to author my scripts. One of the most annoying problem is receiving a no module named xxx error when you already installed that module with pip.
Figure 1: No module error when running Python code in Visual Studio Code
The problem arise because Visual Studio Code is not using the very same installation of python you are using from your command line / terminal. When you edit Python files in Visual Studio Code you should select interpreter path command to specify which version of Python you want to use, as showed in Figure 2:
Figure 2: Choose Python interpreter
This allows you to choose which Python version you want to use, but clearly, when you press F5 that specific version is used and probably you did not install required module in that specific version.
Since Visual Studio Code can use whichever version of Python in your system, you need to install modules for that specific version used.
Once you realize this, solution is straightforward, just install module with pip using the same version of Python chosen as interpreter (Figure 2) using directly python.exe correct version as shown in Figure 3.
Figure 3: Install modules with right version of pip
Once you installed modules using the very same version chosen as interpreter in VSCode, you are ready to go. Pressing F5 you can now debug your code without problem.
Figure 4: Debugging in VSCode after installing required modules
Go to vscode
r/vscode
r/vscode
A subreddit for working with Microsoft’s Visual Studio Code
Members
Online
•
by
shibainuisno1
ORIGINAL
what is «command ‘python.setInterpreter’ not found» error(i use python)?
I tried the following
reinstall vs code
re-install python extension
re-install python
how to repair this?
Archived post. New comments cannot be posted and votes cannot be cast.