question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ipykernel not detected within python virtual environment

See original GitHub issue

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

Following the latest vscode update, I am no longer able to run notebooks that I was able to execute just fine one day earlier. I am using a python virtual environment (not a conda environment) and when running cells I am presented with:

Running cells with 'Python 3.8.10 ('venv': venv)' requires ipykernel package.
Run the following command to install 'ipykernel' into the Python environment. 
Command: '/.../venv/Scripts/python.exe -m pip install ipykernel -U --force-reinstall'

Attempting to reinstall ipykernel does not resolve the problem and I am also presented with the There is no Pip installer available in the selected environment. warning from the Jupyter extension. This behaviour applies to all my projects with venvs, despite function properly before the new release. Switching to a conda global environment seems to resolve the issue, however, I am interested in retaining the functionality of notebooks within the venv virtual environments.

My packages within the venv are:

Package                 Version
----------------------- -----------
absl-py                 1.0.0      
argon2-cffi             21.3.0     
argon2-cffi-bindings    21.2.0     
asttokens               2.0.5      
attrs                   21.4.0     
backcall                0.2.0      
beautifulsoup4          4.11.1     
bleach                  5.0.0      
cachetools              5.0.0      
certifi                 2021.10.8  
cffi                    1.15.0
charset-normalizer      2.0.12
colorama                0.4.4
cycler                  0.11.0
debugpy                 1.6.0
decorator               5.1.1
defusedxml              0.7.1
dython                  0.7.0
entrypoints             0.4
executing               0.8.3
fastjsonschema          2.15.3
fonttools               4.31.2
google-auth             2.6.2
google-auth-oauthlib    0.4.6
grpcio                  1.45.0
idna                    3.3
importlib-metadata      4.11.3
importlib-resources     5.7.1
intel-openmp            2022.0.3
ipykernel               6.13.0
ipython                 8.3.0
ipython-genutils        0.2.0
ipywidgets              7.7.0
jedi                    0.18.1
Jinja2                  3.1.2
joblib                  1.1.0
jsonschema              4.5.1
jupyter                 1.0.0
jupyter-client          7.3.1
jupyter-console         6.4.3
jupyter-core            4.10.0
jupyterlab-pygments     0.2.2
jupyterlab-widgets      1.1.0
kiwisolver              1.4.0
lightgbm                3.3.2
Markdown                3.3.6
MarkupSafe              2.1.1
matplotlib              3.5.1
matplotlib-inline       0.1.3
mistune                 0.8.4
mkl                     2022.0.2
nbclient                0.6.3
nbconvert               6.5.0
nbformat                5.4.0
nest-asyncio            1.5.5
notebook                6.4.11
numpy                   1.22.2
oauthlib                3.2.0
packaging               21.3
pandas                  1.4.0
pandocfilters           1.5.0
parso                   0.8.3
pickleshare             0.7.5
Pillow                  9.0.1
pip                     22.0.4
prometheus-client       0.14.1
prompt-toolkit          3.0.29
protobuf                3.19.4
psutil                  5.9.0
pure-eval               0.2.2
pyasn1                  0.4.8
pyasn1-modules          0.2.8
pycparser               2.21
Pygments                2.12.0
pyparsing               3.0.8
pyrsistent              0.18.1
python-dateutil         2.8.2
pytz                    2022.1
pywin32                 304
pywinpty                2.0.5
PyYAML                  6.0
pyzmq                   22.3.0
qtconsole               5.3.0
QtPy                    2.1.0
requests                2.27.1
requests-oauthlib       1.3.1
rsa                     4.8
scikit-learn            1.0.2
scikit-plot             0.3.7
scipy                   1.7.3
seaborn                 0.11.2
Send2Trash              1.8.0
setuptools              62.1.0
six                     1.16.0
soupsieve               2.3.2.post1
stack-data              0.2.0
tbb                     2021.5.2
tensorboard             2.8.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit  1.8.1
terminado               0.13.3
threadpoolctl           3.1.0
tinycss2                1.1.1
torch                   1.10.2
torchaudio              0.10.2
torchvision             0.11.3
tornado                 6.1
tqdm                    4.62.3
traitlets               5.2.0
typing_extensions       4.1.1
urllib3                 1.26.9
wcwidth                 0.2.5
webencodings            0.5.1
Werkzeug                2.0.3
wheel                   0.37.1
widgetsnbextension      3.6.0
xlrd                    2.0.1
XlsxWriter              3.0.2
zipp                    3.7.0

VS Code Version

Version: 1.67.0 (user setup) Commit: 57fd6d0195bb9b9d1b49f6da5db789060795de47 Date: 2022-05-04T12:06:02.889Z Electron: 17.4.1 Chromium: 98.0.4758.141 Node.js: 16.13.0 V8: 9.8.177.13-electron.0 OS: Windows_NT x64 10.0.19044

Jupyter Extension Version

v2022.4.1011282140

Jupyter logs

Running cells with 'Python 3.8.10 ('venv': venv)' requires ipykernel package.
Run the following command to install 'ipykernel' into the Python environment. 
Command: '/.../venv/Scripts/python.exe -m pip install ipykernel -U --force-reinstall'

Coding Language and Runtime Version

Python v3.8.10

Language Extension Version (if applicable)

No response

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
rchiodocommented, May 13, 2022

The latest build of the jupyter extension should have this fix in it.

This version here:

image

Latest prerelease version too. Please try either one out.

0reactions
abedshantticommented, May 13, 2022

If you run this code from a vscode terminal, does it work? \home.ansatt.ntnu.no\aaalshan\Desktop\Work\Python_Code\GANs\PrivacyGAN\venv\Scripts\python.exe -c "import ipykernel; print(ipykernel.__version__);"

This worked and it printed 6.13.0. Let me know what I should do further in order to get the latest fix 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Installing a ipykernel and running jupyter notebook inside a ...
I'm working in Pycharm IDE (not the professional) and I'm working inside a virtual environment let's call it pythonProject and I want to...
Read more >
What to do when things go wrong - The Jupyter Notebook
What to do when things go wrong¶. First, have a look at the common problems listed below. If you can figure it out...
Read more >
How To Setup Jupyter Notebook in VS Code (w/ Virtual Env ...
Step 1. Create project folder · Step 2. Create, activate & select your virtual environment · Step 3. Install ipykernel · Step 4....
Read more >
Run a new Jupyter Notebook in an already existing virtual ...
Run a new Jupyter Notebook in an already existing virtual environment. Solve not being able to access your virtual environment modules from your ......
Read more >
Working with Jupyter Notebooks in Visual Studio Code
To work with Python in Jupyter Notebooks, you must activate an Anaconda environment in VS Code, or another Python environment in which you've...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found