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 requires ipykernel installed or requires an update. #6272

Closed
DucNgn opened this issue Jun 13, 2021 · 7 comments
Closed

Python requires ipykernel installed or requires an update. #6272

DucNgn opened this issue Jun 13, 2021 · 7 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@DucNgn
Copy link

DucNgn commented Jun 13, 2021

Environment data

  • VS Code version: 1.57.0 (Universal)
  • Jupyter Extension version (available under the Extensions sidebar): v2021.6.999230701
  • Python Extension version (available under the Extensions sidebar): v2021.5.926500501
  • OS (Windows | Mac | Linux distro) and version: MacOS Big Sur 11.3.1
  • Python and/or Anaconda version: python 3.6.0
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Jupyter server running: Local | Remote | N/A: Local

Expected behaviour

  • Click on "start" in the tool bar, it should start running cells

Actual behaviour

The following box appears.

image

  • I tried to reinstall as suggested in the box, it reinstalls ipykernel successfully but the issue still persists.
  • I tried the option to change kernel and verified that the kernel is in the correct venv path.
  • Here's the kernelspec if it helps:
jupyter kernelspec list --json

{
  "kernelspecs": {
    "python3": {
      "resource_dir": "/Users/ducnguyen/workspaces/lab/SHAP-demo/venv/share/jupyter/kernels/python3",
      "spec": {
        "argv": [
          "python",
          "-m",
          "ipykernel_launcher",
          "-f",
          "{connection_file}"
        ],
        "env": {},
        "display_name": "Python 3",
        "language": "python",
        "interrupt_mode": "signal",
        "metadata": {}
      }
    }
  }
}

Steps to reproduce:

  1. Have pyenv to manage python version
  2. Choose python 3.6.0 globally
  3. Start a virtual environment with venv
  4. Start vscode, change kernel path to the one in venv
  5. Create a jupyter notebook file, run cells.
@DucNgn DucNgn added the bug Issue identified by VS Code Team member as probable bug label Jun 13, 2021
@mmarcato
Copy link

mmarcato commented Jun 14, 2021

Hello,

I'm also having a similar issue... I'll add below the main differences:

  • I'm on Windows 10
  • Python version 3.7.10 -> this is what my conda base environment tells me, but then interactive window tries to run on 3.7.4?
  • conda base environment

Expected behaviour:
Interactive window should start, but

Actual behaviour:

image

Things I have tried:

  • updating the ipykernel package with conda to version 5.3.4
    I saw the following steps in another thread and tried them, but didn't work either.
  • deleted the site-packages ipykernel folders
  • updating ipykernel package with pip to version 5.5.5
    Then, I just tried creating a new environement altogether. Then activated the new environment using the command line, installed ipykernel. Same problem.
    image

Some questions about the behaviour:

  1. Why does the kernel try to connect to an older version of python?
    image

Also, if I click 'change kernel':
image
2. Why is the python version different from what I see when I do 'conda list' when base environment is active?
3. Why is the current kernel pointing to the python.exe in conda:'base' environment? Shouldn't it point to the python.exe in the currently active environment named 'venv' in the first place?
4. Finally, it doens't seem to let me choose a new kernel/doesn't recognise other kernel. I just pasted the path to the python.exe in the venv folder, it doesn't do anything...

Also please note that I don't have admin permission on this laptop and I did install python before with admin rights - so I'm afraid this is conflicting with the new version of python which is in a local directory created and I used conda to update it to python 3.7.10.

Thanks very much in advance. I've been stuck in this for 2 days... ;( I don't fully understand how everything works, I'm sorry in advance if anything sounds foundatially wrong.

@deibyrios
Copy link

Environment data

  • VS Code version: 1.57.0 (Universal)
  • Jupyter Extension version (available under the Extensions sidebar): v2021.6.999230701
  • Python Extension version (available under the Extensions sidebar): v2021.5.926500501
  • OS (Windows | Mac | Linux distro) and version: MacOS Big Sur 11.3.1
  • Python and/or Anaconda version: python 3.6.0
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Jupyter server running: Local | Remote | N/A: Local

Expected behaviour

  • Click on "start" in the tool bar, it should start running cells

Actual behaviour

The following box appears.

image

  • I tried to reinstall as suggested in the box, it reinstalls ipykernel successfully but the issue still persists.
  • I tried the option to change kernel and verified that the kernel is in the correct venv path.
  • Here's the kernelspec if it helps:

jupyter kernelspec list --json

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Have pyenv to manage python version
  2. Choose python 3.6.0 globally
  3. Start a virtual environment with venv
  4. Start vscode, change kernel path to the one in venv
  5. Create a jupyter notebook file, run cells.

Same is happening to me

@mmarcato
Copy link

Hey everyone,

I managed to make it work for me, but I'm not 100% sure if my problem is exactly the same as yours. Anyway, here is what I did on Windows (commands will differ depending on OS):

  1. Created a new virtual environment named venv ('py -3 -m venv venv') in my project folder.
  2. Activated the newly created virtual environment ('venv\Scripts\activate').
  3. Select Python interpreter on VS Code (ctrl+shift+p, type 'python: interpreter'), browse to select the python executable in project folder 'env\Scripts\python.exe'
  4. Install ipykernel ('pip install ipykernel') and all other packages necessary to run your code using pip.
  5. You may need to close and open vscode again.

If you have a settings.json file in your project folder, make sure that that is points to the correct python file in your virtual environment ("python.pythonPath": "venv\Scripts\python.exe")

My guess is that this issue has something to do with conda environments.

Hope this helps.

@DonJayamanne
Copy link
Contributor

@dukengn @deibyrios @mmarcato
Please could you upload the output from your Jupyter output panel.
Along with the following information:

  • VS Code Version
  • OS
  • Python version
  • Name of the environment/kernel you are trying to use (screenshot woudl probably capture all of this, when displayin image of the modal dialog box).

@DonJayamanne DonJayamanne added the info-needed Issue requires more information from poster label Jun 15, 2021
@mmarcato
Copy link

Hello @DonJayamanne,
Thanks for getting back to us, for some unknown reason the Jupyter extension is trying to connect to python.exe file outside my virtual environment again -.-

  • VS Code Version: 1.57.0 (user setup)
  • Windows 10
  • Python: well in my virtual environment 3.8.1, the base environment is 3.7.4 which I've no clue why it is trying to connect to that.
  • See below. I name my virtual environment 'venv' it is in my project folder as you can see on the left side. Note the interpreter is selected correctly and I have ipykernel in that virtual environment (highlighted on the left).

image

I guess the main question is: why is jupyter trying to connect to the base environment instead of venv?

@DonJayamanne
Copy link
Contributor

some unknown reason the Jupyter extension is trying to connect to python.exe

Please could you upload the contents from the Jupyter output panel

@greazer
Copy link
Contributor

greazer commented Aug 7, 2021

Issues labeled with "Info needed" are closed if we do not receive more information from the issue author in 2 weeks. If you are the issue author and you still are running into this problem, please reactivate with additional information.

@greazer greazer closed this as completed Aug 7, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2021
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

6 participants