3

I'm using the vscode extension importmagic which works fine when not working in a remote container. In the remote container I don't see my own classes and functions as suggestions for autocomplete.

I've tried adding

        "python.autoComplete.extraPaths": [
            "${workspaceFolder}",
        ],

to the settings in devcontainer.json where workspaceFolder=/app. If I set it to ${workspaceFolder}/module it gives me suggestions for the underlying modules.

For example I have a structure like module/sub_module/sub_sub_module and it will suggest and add import automatically like from sub_module.sub_sub_module import ... but module is not included in the import so the import can't be resolved.

Is there a setting that I'm missing or why can't it detect underlying module when using only workspaceFolder as extraPaths?

4 Answers 4

6

Change the Python-Server in settings.json from "Pylance" or "Microsoft" or whatever you are using- to "Jedi"

"python.languageServer": "Jedi"

To be honest, no solutions worked for me except this one.

One of the solution is keep adding all the paths to extraPaths which doesn't sound good. Instead use "Jedi" server. No need to add any extraPaths, it uses the directory of open files and folders for autocomplete and analysis by default.

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

1 Comment

Thanks, @hexr this helped me to find a solution. I set it to "Jedi" and I'd rebuilt my dev container. A warning message showed up "IntelliCode Python support requires you to use the Microsoft Python Language Server." I clicked the button "Enable it and Reload Window". It changed it from "Jedi" to "Microsoft" and voila. I also tried adding a line to my Dockerfile "RUN pip install jedi" and reset the settings.json to use Jedi but nothing. I guess this is somehow related to the Python VS Code extension I'm using. Its provided by Microsoft. But, now it's working for me so I left on MS.
4

You need to make sure that the extensions installed locally in vscode are also installed in the remote container. In your case the Python extension that allows the autocomplete features and many others are not installed.

Try to access to Preferences/Extensions and install them manually.

Comments

3

Make sure VSCode is using the Python Interpreter from the container (instead of your local). You can do that in VSCode by typing cmd + p -> Python: Select Interpreter -> Select the version from the container.

Comments

0

For Me it Worked to click on the left side to the Extensions and scroll down to Pylance. There is a button with "On: SSH: XXX. ... install". After the Install everything works fine.

Comments

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.