11

Here is how the thing doesn't work:

The project source code is located on a remote machine. The Python virtual environment is installed in the project's root directory (using venv).

I sshfs the project folder and start local VSCode. It detects the virtual environment, but doesn't see pylint or other packages installed in it.

Python 3.6.7 VS Code - latest version OSs - Debian 9 remote, Linux Mint 19 local Both sshfs connection and venv installation are performed under the same account.

Is there some special way a virtual environment should be set up to be usable remotely?

3 Answers 3

11

There were problems with sshfs in early VSCode versions, but recent distrib has Remote Development extension that lets you develop your code via ssh.

Since you have activated your virtual environment, just get venv python path with which python command and copy it to the Select Interpreter menu.

Sign up to request clarification or add additional context in comments.

Comments

5

Activate your python environment:

source venv/bin/activate 

Find which python path you are using:

which python

Usually it is in :

venv/bin/python

Go to the bottom of VS Code, and click on the version number :

enter image description here

Click on Enter interpreter path... : enter image description here

Enter the path you found above with the which python command.

2 Comments

When using VSCode 1.70.2 and ssh-ing to a remote machine, I do not see any number after 'Python', just 'Python' itself.
@ComputerScientist you can do python --version in that case
1

You have to install python extensions on remote ssh for this to work.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.