VSCODE - remote ssh with python 3.9?

Viewed 173

How can I execute python 3.9 using remote ssh through vscode?

When I connect to the server, it only run as 2.6

My code:

from platform import python_version
  
print("Current Python Version-", python_version())

output:

[Running] python -u "/root/python/projetos.py"
('Current Python Version-', '2.6.6')

Is there any way to select the python version through vscode? I've tried to change at Linux level (using alternative command), but don't work.

What I need is vscode to call python3.9 command instead of python command :

[root@quickstart ~]# python --version
Python 2.6.6
[root@quickstart ~]# python3.9 --version
Python 3.9.10
[root@quickstart ~]#
1 Answers

I've find out.

Need to install python vscode extension on remote ssh server.

When connected to the SSH Server, in extensions (Ctrl + shift + x), look for python and so, install in SSH:

enter image description here

After install, type Ctrl + shift + p and look for Python: select interpreter.

enter image description here

And here will show all python interpreters paths installed on the server.

enter image description here

Related