Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python autocompletion doesn't work with VS Code Python extenstion (Pylance) #892

Closed
2 tasks done
an4s911 opened this issue Oct 28, 2021 · 21 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@an4s911
Copy link

an4s911 commented Oct 28, 2021

Describe the bug
When I am using VS Codium and have the VS Code Python and Pylance extensions installed and enabled, I don't get any autocomplete options or suggestions and it shows No suggestions.

Screenshot from 2021-10-28 18-56-31

As you can see I have enabled only the Python extension and it shows No suggestions. Now when I disable I get some suggestions but they are not Python suggestions, but rather just suggesting text from other parts of the file.

Screenshot from 2021-10-28 18-56-53

But not even this works when the extension is turned on.

Please confirm that this problem is VSCodium-specific

  • This bug doesn't happen if I use Microsoft's Visual Studio Code. It only happens in VSCodium.

Please confirm that the issue/resolution isn't already documented

Desktop (please complete the following information):

  • OS: Ubuntu 20.04 LTS
  • Architecture x64
  • Version 1.61.2
@an4s911 an4s911 added the bug Something isn't working label Oct 28, 2021
@an4s911
Copy link
Author

an4s911 commented Oct 28, 2021

I think I kinda figured it out. When I install the Python Extension it installs another extension along with it called Pylance. And that is the one that is causing this problem. When I disable Pylance the autocompletion works. I have to test it out on the original VS Code as well to know if it is a problem of Pylance or VSCodium. And if the problem is with Pylance [Hopefully] I will close this Issue

@an4s911
Copy link
Author

an4s911 commented Oct 28, 2021

I tested Pylance on the original VS Code and VSCodium and it seems like the problem exists only on the latter. I don't know if this is a problem only for me or anyone else. So if someone else tested it out and comment their observations it might be helpful.

PS: To be honest, I don't mind using the Python Extension only (ie without Pylance).

@ghtmtt
Copy link

ghtmtt commented Oct 29, 2021

@an4s911 confirmed here as well with version 1.61. It seems to me that the last working release is the 1.56

@an4s911 an4s911 changed the title Python autocompletion doesn't work with VS Code Python extenstion Python autocompletion doesn't work with VS Code Python extenstion (Pylance) Oct 29, 2021
@SebastianGrans
Copy link

The issue is that Microsoft prevents PyLance from being used in non-official builds.
A workaround is to modify the product.json file, and set nameLong to "Visual Studio Code".

Source: https://www.reddit.com/r/linux/comments/k0s8qw/comment/ggnqes7/

@ghtmtt
Copy link

ghtmtt commented Nov 2, 2021

@SebastianGrans thanks for sharing but still I don't get the extension working. I've changed the product.json file with the instruction of reddit but still nothing

@SebastianGrans
Copy link

@ghtmtt What does it say in the Python output terminal?

Before I change nameLong:

Starting Pylance language server.
Error 2021-11-02 17:21:36: Failed to start language server, Class name = r, completed in 0ms, has a falsy return value, Arg 1: <Uri:/home/grans/Documents/harvesters_gui/Utils/CameraCalibration.py>, Arg 2: {"sysPrefix":"/usr","envType":"Global","envName":"","envPath":"","path":"/bin/python" [... etc] 

After I change, it simply prints:

Starting Pylance language server.

with no error after it.

@ghtmtt
Copy link

ghtmtt commented Nov 2, 2021

@ghtmtt What does it say in the Python output terminal?

if you mean running a file in the python terminal I can do it without any problem. I just have issues with the autocompletion

@SebastianGrans
Copy link

@ghtmtt No. What I mean is the output from the Python extension.

You can see its output by opening a terminal inside Codium, and then go to the output tab, and select Python. See the screenshot below.
Screenshot 2021-11-02 at 20 57 34

@ghtmtt
Copy link

ghtmtt commented Nov 2, 2021

This is what I have

 /bin/python ~/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/pythonFiles/interpreterInfo.py
> /usr/bin/python ~/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/pythonFiles/interpreterInfo.py
> /usr/bin/python3 ~/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/pythonFiles/interpreterInfo.py
> ~/.local/share/r-miniconda/bin/python ~/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/pythonFiles/interpreterInfo.py
> ~/.local/share/r-miniconda/envs/r-reticulate/bin/python ~/.vscode-oss/extensions/ms-python.python-2021.10.1365161279/pythonFiles/interpreterInfo.py
Starting Pylance language server.

@SebastianGrans
Copy link

Could you post your user settings.json file?

It could also be an extension that is interfering, so try disabling all extensions that aren't needed and see if that helps.
It works for me with these extensions active:
extensions

@ghtmtt
Copy link

ghtmtt commented Nov 3, 2021

Could you post your user settings.json file?

{
    "python.autoComplete.extraPaths": [
        "/home/matteo/dev/qgis-master/output/python/qgis/",
        "/home/matteo/dev/qgis-master/output/python/"
    ],
    "workbench.colorTheme": "Quiet Light",
    "python.autoComplete.addBrackets": true,
    "python.pythonPath": "/bin/python3",
    "explorer.confirmDragAndDrop": false,
    "atomKeymap.promptV3Features": true,
    "editor.multiCursorModifier": "ctrlCmd",
    "editor.formatOnPaste": true,
    "editor.rulers": [
        80
    ],
    "python.formatting.provider": "none",
    "[restructuredtext]": {
        "editor.wordWrapColumn": 80,
        "editor.wordWrap": "on",
        "editor.acceptSuggestionOnEnter": "off"
    },
    "workbench.colorCustomizations": {
        "editor.selectionBackground": "#ced12d",
    },
    "diffEditor.ignoreTrimWhitespace": true,
    "jupyter.interactiveWindowMode": "perFile",
    "jupyter.sendSelectionToInteractiveWindow": true,
    "workbench.editorAssociations": {
        "*.ipynb": "jupyter.notebook.ipynb"
    },
    "autoDocstring.docstringFormat": "sphinx",
    "python.analysis.completeFunctionParens": true,
}

I've disable most of the extensions but still nothing. No external API and not standard autocomplete

@gerroon
Copy link

gerroon commented Nov 4, 2021

I have the same issue on Windows 10, VsCodium 1.61.2

I originally was not getting even classes and functions in the outline so I removed Pylance, which helped with the Outline but I now have no autocompletion.

This use work fine in early versions this year but I cant tell the last working version.

@dimitrov-dimitar
Copy link

The issue is that Microsoft prevents PyLance from being used in non-official builds. A workaround is to modify the product.json file, and set nameLong to "Visual Studio Code".

Source: https://www.reddit.com/r/linux/comments/k0s8qw/comment/ggnqes7/

Thank you, it worked for me too. 👍

@ghtmtt
Copy link

ghtmtt commented Nov 8, 2021

Thank you, it worked for me too. +1

I've already tried this solution but it never worked for me. BUT it seems that the combination of 2 different changes in the product.json file makes the things working again!

{  
  "nameShort": "Visual Studio Code",
  "nameLong": "Visual Studio Code",
  ...
  ...
  "extensionsGallery": {
    "serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
    "cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
    "itemUrl": "https://marketplace.visualstudio.com/items"
  },

@brccabral
Copy link
Contributor

where is "product.json" located?

@brccabral
Copy link
Contributor

Found it, need to edit file prepare_vscode.sh before compile

@daiyam
Copy link
Member

daiyam commented Dec 1, 2021

The python extension is tricky since it's using a closed source server (pylance).
I do believe that the best course of action would for some python devs to fork that extension and replace the closed source part with a new open source project.

@clayrisser
Copy link

Use the jedi language server instead of pylance.

@an4s911
Copy link
Author

an4s911 commented Dec 6, 2021

The issue is that Microsoft prevents PyLance from being used in non-official builds. A workaround is to modify the product.json file, and set nameLong to "Visual Studio Code".

Source: https://www.reddit.com/r/linux/comments/k0s8qw/comment/ggnqes7/

Thanks. Just like some others have mentioned, this worked for me as well. I think I will close the issue now as the issue is solved for me as well as others.

If the above mentioned solution didn't work then try the below and it should probably fix it.

Thank you, it worked for me too. +1

I've already tried this solution but it never worked for me. BUT it seems that the combination of 2 different changes in the product.json file makes the things working again!

{  
  "nameShort": "Visual Studio Code",
  "nameLong": "Visual Studio Code",
  ...
  ...
  "extensionsGallery": {
    "serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
    "cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
    "itemUrl": "https://marketplace.visualstudio.com/items"
  },

And I am closing this Issue. Thanks to everyone who helped and contributed ✌

@asdorsey
Copy link

Sorry for issue necromancy, but I found another potential solution today:
Uninstall the Microsoft Python extension and install the Pyright extension instead. It's still Microsoft, but it provides auto-completion and error checking, and works on VSCodium out of the box without modification.

@an4s911
Copy link
Author

an4s911 commented Mar 25, 2022

@asdorsey Thanks. I will check it out

nymous added a commit to nymous/dotfiles that referenced this issue Apr 12, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants