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

VSCode tries to install pip and ipykernel on WSL2 with venv and ipykernel already configured #9416

Closed
chrisdlangton opened this issue Mar 18, 2022 · 5 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@chrisdlangton
Copy link

Version

Microsoft Windows [Version 10.0.22572.100]

WSL Version

WSL 2

Kernel Version

5.10.93.2

Distro Version

Ubuntu 20.04

Other Software

via pip
ipykernel 6.9.2

VSCode
February 2022 (version 1.65)
Remote - WSL v0.64.2

Repro Steps

as described https://code.visualstudio.com/docs/datascience/jupyter-notebooks
ran python3.9 -m venv .venv
then in VSCode Ctrl+Shift+P selected the .venv/bin/python
ensured Workspace Trust was given
created a new .ipynb file and opened it in VSCode
selected the kernel using the kernel picker in the top right and chose .venv/bin/python
added print("works") to the cell, made sure it was a "Python" cell. Shift+Enter
prompts to install ipykernel using pip, I clicked "install" and a terminal inside VSCode runs the commands and the output of these are below in the diagnostic logs.

I install ipykernel myself and the following packages were also installed;

Successfully installed asttokens-2.0.5 backcall-0.2.0 debugpy-1.5.1 decorator-5.1.1 entrypoints-0.4 executing-0.8.3 ipykernel-6.9.2 ipython-8.1.1 jedi-0.18.1 jupyter-client-7.1.2 jupyter-core-4.9.2 matplotlib-inline-0.1.3 nest-asyncio-1.5.4 parso-0.8.3 pexpect-4.8.0 pickleshare-0.7.5 prompt-toolkit-3.0.28 psutil-5.9.0 ptyprocess-0.7.0 pure-eval-0.2.2 pygments-2.11.2 python-dateutil-2.8.2 pyzmq-22.3.0 setuptools-60.9.3 six-1.16.0 stack-data-0.2.0 tornado-6.1 traitlets-5.1.1 wcwidth-0.2.5

As shown ipykernel-6.9.2 now exists
in the cell Shift+Enter prompts to install ipykernel using pip again, and the exact same output in the diagnostic logs.

Expected Behavior

I have ipykernel installed and i have pointed VSCode to use the correct venv and correct kernel location. pip is installed so why is VSCode stuck on get-pip ?? I expect to just have the cell execute with this setup.

off topic; worth adding so it is not in any reply. Both a remote (in docker) Jupyter server AND using the host python/pip works just fine but both are not in-scope to this issue.

Actual Behavior

VSCode tried to install pip, and there is a setuptools issue related to the pip install already being complete.
pip is available to VSCode in all other aspects of the VSCode+Python/Pylance operation, it is just when using Jupyter VSCode is mistaken in trying to install pip for no good reason. When that fails it is a red herring, VSCode should not be trying to install pip or the ipykernel in the first place.

This issue aims to have a python interpreter via the venv and the ipykernel installed into that venv (not in docker or on the host).

Diagnostic Logs

/home/wsl/bitbucket/.venv/bin/python /home/wsl/.vscode-server/extensions/ms-python.python-2022.2.1924087327/pythonFiles/shell_exec.py /home/wsl/bitbucket/.venv/bin/python /home/wsl/.vscode-server/extensions/ms-python.python-2022.2.1924087327/pythonFiles/get-pip.py /tmp/tmp-84767YuKhpR6lHjS.log
Executing command in shell >> /home/wsl/bitbucket/.venv/bin/python /home/wsl/.vscode-server/extensions/ms-python.python-2022.2.1924087327/pythonFiles/get-pip.py
/tmp/tmpe9vcmjw1/pip.zip/pip/_vendor/packaging/version.py:111: DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
/tmp/tmpe9vcmjw1/pip.zip/pip/_vendor/packaging/version.py:111: DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
/home/wsl/bitbucket/.venv/lib/python3.9/site-packages/_distutils_hack/__init__.py:17: UserWarning: Distutils was imported before Setuptools, but importing Setuptools also replaces the `distutils` module in `sys.modules`. This may lead to undesirable behaviors or errors. To avoid these issues, avoid using distutils directly, ensure that setuptools is installed in the traditional way (e.g. not an editable install), and/or make sure that setuptools is always imported before distutils.
  warnings.warn(
/home/wsl/bitbucket/.venv/lib/python3.9/site-packages/_distutils_hack/__init__.py:30: UserWarning: Setuptools is replacing distutils.
  warnings.warn("Setuptools is replacing distutils.")
Traceback (most recent call last):
  File "/home/wsl/.vscode-server/extensions/ms-python.python-2022.2.1924087327/pythonFiles/get-pip.py", line 27086, in <module>
    main()
  File "/home/wsl/.vscode-server/extensions/ms-python.python-2022.2.1924087327/pythonFiles/get-pip.py", line 144, in main
    bootstrap(tmpdir=tmpdir)
  File "/home/wsl/.vscode-server/extensions/ms-python.python-2022.2.1924087327/pythonFiles/get-pip.py", line 125, in bootstrap
    args = determine_pip_install_arguments()
  File "/home/wsl/.vscode-server/extensions/ms-python.python-2022.2.1924087327/pythonFiles/get-pip.py", line 67, in determine_pip_install_arguments
    import setuptools  # noqa
  File "/home/wsl/bitbucket/.venv/lib/python3.9/site-packages/setuptools/__init__.py", line 8, in <module>
    import _distutils_hack.override  # noqa: F401
  File "/home/wsl/bitbucket/.venv/lib/python3.9/site-packages/_distutils_hack/override.py", line 1, in <module>
    __import__('_distutils_hack').do_override()
  File "/home/wsl/bitbucket/.venv/lib/python3.9/site-packages/_distutils_hack/__init__.py", line 72, in do_override
    ensure_local_distutils()
  File "/home/wsl/bitbucket/.venv/lib/python3.9/site-packages/_distutils_hack/__init__.py", line 59, in ensure_local_distutils
    assert '_distutils' in core.__file__, core.__file__
AssertionError: /usr/local/lib/python3.9/distutils/core.py
Traceback (most recent call last):
  File "/home/wsl/.vscode-server/extensions/ms-python.python-2022.2.1924087327/pythonFiles/shell_exec.py", line 26, in <module>
    subprocess.check_call(shell_args, stdout=sys.stdout, stderr=sys.stderr)
  File "/usr/local/lib/python3.9/subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/wsl/bitbucket/.venv/bin/python', '/home/wsl/.vscode-server/extensions/ms-python.python-2022.2.1924087327/pythonFiles/get-pip.py']' returned non-zero exit status 1.

❯ pip --version
pip 22.0.4 from /home/wsl/bitbucket/.venv/lib/python3.9/site-packages/pip (python 3.9)
@rebornix rebornix transferred this issue from microsoft/vscode Mar 18, 2022
@DonJayamanne DonJayamanne assigned DonJayamanne and unassigned rebornix and amunger Mar 21, 2022
@rchiodo rchiodo added info-needed Issue requires more information from poster bug Issue identified by VS Code Team member as probable bug and removed needs-triage labels Mar 28, 2022
@DonJayamanne
Copy link
Contributor

THanks for filing this issue, I"m sorry you're running into this.
Please could you send all of the output from the Jupyter output panel.

@chrisdlangton
Copy link
Author

THanks for filing this issue, I"m sorry you're running into this. Please could you send all of the output from the Jupyter output panel.

That IS the whole output, the first thing it tries to do is install pip via python's built in get-pip/py, and as explained it is unnecessary to even try that and clearly fails because it tries to install old distutils (because get-pip is not maintained)

again, VSCode should not try to install pip ever anyway, and if it actually just used the pip installed and callable there would be no issues like this from trying to install old deprecated code over an updated environemnt

@DonJayamanne
Copy link
Contributor

again, VSCode should not try to install pip ever anyway, and if it actually just used the pip installed and callable there

The reason we're trying to install pip is we've haven't been able to install pip. We've found a number of instances where pip isn't available hence we decided to install that and unblock the users. However that logic seems to be failing in your case.

That IS the whole output, the first thing it tries to do is install pip via python's built in get-pip/py, and as explaine

Please confirm you are sending all of the output from here :

image

@DonJayamanne
Copy link
Contributor

@chrisdlangton just chekcing if you've managed to get the logs for this issue.

@DonJayamanne
Copy link
Contributor

Closing this issue as its been over 4 weeks, since the information was requested.
We'll be happy to reopen the issue when the requested information has been provided.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

5 participants