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?
From within VS Code, you can create non-global environments, using virtual environments or Anaconda, by opening the Command Palette (Ctrl+Shift+P), start typing the Python: Create Environment command to search, and then select the command. The command presents a list of environment types: Venv or Conda.
Activate an existing virtual environmentRight-click Python Environments in Solution Explorer and select Add Environment. In the Browse dialog that appears, navigate to and select the folder that contains the virtual environment, and select OK. If Visual Studio detects a requirements.
Connect to a remote host Verify you can connect to the SSH host by running the following command from a terminal / PowerShell window replacing user@hostname as appropriate. In VS Code, select Remote-SSH: Connect to Host... from the Command Palette (F1, Ctrl+Shift+P) and use the same user@hostname as in step 1.
Create a Project Environment Then run Terminal: Create New Terminal (Ctrl+Shift+`)) from the Command Palette, that opens a new python terminal and in parallel it activates the virtual environment.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With