VSCode Python IntelliSense Not working On Remove Machine - python

I use VSCode "Remote-SSH" to access a VM to do all my coding.
On the VM I have installed the "Python" and "Pylance" extensions hoping to get IntelliSense autocomplete.
My python interpreter is not in the "typical" /usr/bin/python3 location. So I have the following setting in my VM's setting.json:
"python.defaultInterpreterPath": "/some/path/to/3.6.8/python3",
I have successfully enabled python lint. Although my IntelliSense autocomplete isn't working at all. When I type I don't see any pulldown menu or error messages.
What could I possibly be missing?

Related

Visual Studio Code - Intellisense not working on SSH server even though it's installed

So for some reason my intellisense is not working.
I tried the solutions suggested here Visual Studio Code: Intellisense not working.
The solution that seems to help most people is adding "python.autoComplete.extraPaths": [ "${workspaceFolder}/customModule" ], didn't work. Also VS Code says it doesn't recognize python.pythonPath when I add it.
Auto-complete not working, screen capture didn't capture my cursor, but it's right after argparse., which should give the option to auto-complete with a list that includes: ArgumentParser:
Remote server installed extensions:
Settings.json
This is settings.json on remote server
{
"remote.autoForwardPortsSource": "output",
"python.languageServer": "None",
"python.analysis.completeFunctionParens": true,
"python.analysis.diagnosticMode": "workspace",
}
Setup:
Running using Conda env
Linux remote server
Note:
Something else off is my "find declaration of function or class" is also not working.
the first solutions are kind of obvious, but ill add them anyway,
Removing reinstalling it both locally and remotely
Make sure VS code is updated to its last version
In settings.json, set a language server in "python.languageServer". The Language Server includes: Jedi(build-in Python extension ), Microsoft, Pylance, since you have already installed Pylance, let's start with that one (if that doesnt work, try the others).
set your python.pythonPath to the path returned in your terminal for which python3

Not automatically lintering with the python interpreter (Python Extension)

I recently installed VScode on Ubuntu, and now it doesnt automatically linter the code using the python interpreter (as it did on Windows). This is really annoying me because I have to save the file every time I want it to linter.
Any answers are greatly appreciated
If you need more info, just let me know and I will provide it
By default, linting for Python is enabled in Visual Studio Code using Pylint, and you can enable other linters of your choice. You can easily enable and disable all linting by using the Python: Enable Linting command. Also you can verify your linting settings:
Go to Settings and check the which linting rules you have enabled :
Go to Command Palette and check if the linter is enabled:
More info: https://code.visualstudio.com/docs/python/linting
There is a setting called Python: Jedi Enabled(looks like this). If you switch if off and then restart VSCode, the issue should be fixed

PEP8 inspection in PyCharm not working with Docker remote python interpreter

I use local python interpreter, pep8 work well and I see all warnings in my files.
Then I switch to remote python interpreter from Docker, all warnings disappeared.
Python on local and Docker: 2.7.12
Pycharm: PyCharm 2017.3.3 (Professional Edition) Build #PY-173.4301.16, built on January 11, 2018
As explained here, Pycharm needs a local interpreter in order to inspect the code. For me, the following worked:
Create a new (dummy) project
Configure a local Python interpreter for the dummy project
Close Pycharm
Open Pycharm and then open your original project that uses the remote interpreter
PEP8 inspection works! (granted that it is enabled in the settings)
Basically my understanding is that it needs a local interpreter to be configured for some project but not necessarily for the specific project you want to run the inspection on.

Visual Studio Tools for AI - Variable Explorer not loading

Installed VS Tools for AI and tried to run a python deep learning script.
The script runs well on the Anaconda Interactive provided by the IDE. Problem is with the 'Variable Explorer'. It shows an error saying "Error retrieving environment list".
The Default python environment is set to Anaconda 4.4.0.
Any solution to get the prevailing variables in the executing script through the explorer?
(The comment from Jespar is correct, so promoting it to an answer.)
That Variable Explorer belongs to R tools, so it will only work when you are using R.
There is currently no variable explorer for Python in Visual Studio, so this will not work. The two options to inspect variables are to debug a script (set a breakpoint and use the Watch/Locals windows), or use the interactive window (and the normal Jupyter-style commands, if you've enabled "IPython interactive mode" from the Python Environments window).

Pycharm cannot find libraries from remote virtualenv, even when correct interpreter specified

I want to use Pycharm as IDE to upload my python code to a remote server. On this server I have a virtual environment with virtualenv. This interpreter is specified in the project interpreter settings and when I look at the installed packages, it finds all the packages, but when I program, all the imports I use are not found and hence autocomplete does not work and my whole code is full of errors which is quite annoying. I use Pycharm on a windows computer and the server runs on Ubuntu 14.04.
As can be seen on the figure, the project interpreter uses an ssh connection to the server, and my path to the python interpreter is set to the python interpreter of the virtual environment (not the default python on that server). All the installed packages are also shown. Should I configure something else to make Pycharm find these modules (allthough I think pycharm finds them as they show up in the picture, but it does not use them for imports)?
I had a similar problem, but not with a remote interpreter.
I found that the Run Configuration was set to use a different interpreter than the Project Settings.
Settings / Preferences > Project: untitled > Project Interpreter =>
~/project/venv/bin/python
All good. But:
Run Configuration > Python interpreter => /usr/local/bin/python3.7
The top choice on the drop-down list for the Run Configuration interpreters was Project Default which set it to the same as my project setting.
Run Configuration > Python interpreter => Project Default
(~/project/venv/bin/python)
I don't know if this is the cause of your problem, but it's something to check.
As discussed in PY-29551 PyCharm does not yet support remote virtual environments with remote interpreters (only global Python environments). Apparently they will add this any moment in PY-6002.
Until then I solved this with the workaround suggested in PY-29551:
For simply deploying and running code the workaround with adding a "pseudo" python executable that just loads the venv before running python worked for me:
#!/bin/sh
. /home/me/mypy/venv/bin/activate
exec python $*
Just add this to your remote venv and select it as Python executable instead.
For remote debugging this did not work for me, so for debugging I instead went for the Remote Debug Server approach described in the offical PyCharm docs on remote debugging.

Categories

Resources