1

I have been trying to change my python interpreter on sublime text and VS code and no matter what I do, both of them refuse to change. It always picks the default Python 2.7 version.

On sublime, I tried to create a new build tool, added the path to Python3 but nothing is working.

Sublime Text Image

And on, VS code, even if I select Python3 from the drop-down menu, it doesn't change anything.

Visual Studio Image

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
punit1337
  • 21
  • 1
  • 10

4 Answers4

1

I changed the system's default python interpreter from 2.7 to 3.9 and set the path on bash profile. It fixed the issue for me.

punit1337
  • 21
  • 1
  • 10
0

I don't know about Sublime, but for VS Code, there looks to be quite a few things to verify:

  1. Check your User Settings on whether you've set up a default interpreter for your applications
  2. Are you using Window 10 WSL? Then you might want to check out issue 3227 for vscode-remote-release where the comment was:

So I was having this same exact issue until I read this article on a wsl tutorial. In there it says we should have "Remote - WSL" extension installed (already did). In the bottom left corner "Remote - WSL" installs a status button that has the "greater than" and "less than" symbols displayed. If you click that button and tell VSCode to open up in the remote WSL distro environment it fixed my issue where vscode was unable to find an interpreter for python.

Viet Than
  • 164
  • 1
  • 10
0

For Sublime, you need to hit B with your script pane focused in order to use your new python3.sublime-build build system.

It looks like you are running your script within Terminus, which is fine, but you need to use the python3 command when running it from the command line, even if that command line is within Sublime.

Please check out my answer here on how to make a Python build system that accepts user input, as the Sublime "console" doesn't allow you to interact with your program. Since you already have Terminus installed, I'd recommend going down to the bottom of the answer and using the Terminus build system. That way, you won't have to deal with Terminal windows opening every time you run a build.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
0

The terminal window uses your PATH, not the IDE settings, so manually typing out python --version isn't testing anything except the PATH variable

In order for the terminal to use the "correct" python binary you've specified, it would need to give the absolute path to it, which I believe using Command+B (using the build options) in Sublime would do. Similarly, you can use the Run/Debug Configurations in VSCode.

Or you can modify your ~/.zshrc to fix your PATH, for example installing pyenv to change the entire system Python version, or the one for the current folder

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • I changed the system's default python interpreter from 2.7 to 3.9 and set the path on bash profile. It fixed the issue for me. – punit1337 Jun 18 '21 at 02:28