Problem:
When I try running code by line (f10) with VS Code, "ipykernel setup required for this feature" message pops up.
What I've tried:
Using Anaconda Prompt: "conda install ipykernel", "conda install -c conda-forge ipykernel"
-When I tried this, the prompt said "conda-forge:: ipykernel-6.4.1-py38h595 --> pkgs/main:: ipykernel-6.2.0-py38haa95532_1"
Doesn't it mean I already install ipykernel v.6.20 or higher?
After I tried this I checked Jupyter --Version it said ipykernel 5.3.2
Other specs are qualified. (VS Code, Jupyter, Anaconda versions etc,)
Using Terminal (in VS Code): "pip install ipykernel"
Reinstalling all of add-ins such as Python for VS, Python, Anaconda, Jupyterlab, VS Code
Updating ExecutionPolicy: CurrentUser-RemoteSigned, LocalMachins-AllSigned, others Undefined.
+) Created virtual-env named envi which is conda env. In VS Code I selected this interpreter and also reloaded all windows.
As I understand, Conda install Ipkkernel > Reload is what pop-up msg required.
This is what I'm going through now.. I just got interested in Python and now I cannot doing anything..
I had the same problem. It seems there was a problem with the version of ipython or ipykernel since I managed to fix it by running the following commands in conda environment:
pip install --upgrade ipython
pip install --upgrade ipykernel
Don't know which of the two was the problem but I was able to use the jupyter notebook line-by-line feature after this.
I have recently uninstalled python 3.7 and installed python 3.9. After that, when I try to use pip to install any package, it keeps trying to use python37.exe, which is not installed anymore. I was able to solve that by using python -m pip install, but the same does not work when I try to launch jupyter notebook, which still tries to use python37. I cannot launch it using a similar command python -m jupyter notebook.
I was wondering if there is any solution to this, since I could not find anything related to that.
Thanks in advance.
Maybe try to install it again using your new pip like
pip install notebook
(Sorry not enough reputation for a comment)
This usually occurs when jupyter is installed with a specific version of python. The easiest / best solution is to uninstall jupyter, then reinstall it with the correct version of python.
In your case, you should consider using python3.9 -m pip install jupyter (after first uninstalling jupyter).
Just to give you all an update in case anyone is facing the same problem.
I was able to find some remaining files and files of the previous installation of Python 3.7 in my system that were not deleted for some reason during the uninstall process. I deleted them manually and my system started to recognize Python 3.9 to call pip and jupyter after that.
I am trying to make a jupyter notebook in visual studio code but I keep getting this:
''Unable to start session for kernel Python 3.8.3 64-bit ('Lenovo':
virtualenv). Select another kernel to launch with.''
I have anaconda installed and the jupyter notebook works fine in the anaconda navigator. I also tried to use python 3.8.3 base:'conda' but it didnt work. I'm using windows 10
This issue also occurs on my computer. The solution is to restore the version number of a dependency package "traitlets" of ipython kernel to 4.3.3.
You could try to use "pip list" to view the version of the module "traitlets" in the current virtual environment. If it shows version 5.0, it is recommended that you use version 4.3.3.
You could reinstall "traitlets 4.3.3" with the following command:
python -m pip install 'traitlets==4.3.3' --force-reinstall
If this command is not available, you could use 'pip' to uninstall traitlets5.0 (pip uninstall traitlets) and then use 'pip' to install traitlets4.3.3.(pip install traitlets==4.3.3)
Reference: Unable to start session for kernel Python.
I had the exact same problem. Fix it by uninstalling the Python extension that is linked to that error message.
If you are using conda to manage your Python environments, activate your target environment at a command prompt, then enter the following:
$ conda install traitlets=4.3.3
This solved the problem for me.
I've installed Jupyter extension in the latest Visual Studio:
Visual Studio 1.3.01 64
Jupyter 1.1.4
As I am using tensorflow I need Python 3 64bit.
When I try to run simple code I get:
Jupyter kernel cannot be started from 'Python 3.6.8 64-bit ('tensorflow64': virtualenv)'. Using closest match Python 3.7.0 32-bit instead.
Code:
#%%
import tensorflow as tf
session = tf.Session()
hello = tf.constant("Hello from Milan.")
print(session.run(hello))
a = tf.constant(20)
b = tf.constant(22)
print('a + b = {0}'.format(session.run(a + b)))
All works fine if I Run code not using Jupyter from VS Code.
Message from Jupyter is not the best description of the issue, missing ipykernel package.
Fix was to install additional python package 'ipykernel' into virtual environment with Python 3.64 bit.
pip install ipykernel
Additional info:
https://github.com/Microsoft/vscode-python/issues/3579
conda create --name test_env
conda activate test_env
conda install -c anaconda ipykernel
python -m ipykernel install --user --name=test_env
Or this You can run this it might work
ipython kernel install --user --name=ENVNAME
Simple installation is the best. While learning Python et-all I had installed many things in many different ways. It was a mess. Removed everything and did a fresh install only I used pyenv and pipenv. However pipenv does not work with the latest version which you can install using brew. Solution revert back to version 2018.10.13 using pip install. Then I discovered that pipenv was no longer recommended so, I removed it. Built a test project and could not get jupyter to run. Spent all day trying everything.
Solution was, remove the old version of pipenv and install the latest using brew. All is well.
However, I do like the features of pyenv like setting global etc.
You have to select and save the .ipynb file with VSCode indicating a kernel that is reachable from your Jupyter installation:
In my case installing anaconda and call following comments solves it:
conda create -n tf tensorflow
conda activate tf
In Jupyter Notebook, ipywidgets work fine, however they seem to not work in Jupyter Lab (which is supposedly better than Notebook).
I followed these directions.
Step 1: Installed Node.js (https://nodejs.org/en/)
Step 2: Installed requirements on Python 3 with conda:
conda install -c conda-forge ipywidgets
jupyter labextension install #jupyter-widgets/jupyterlab-manager
Unfortunately, basic widgets do not work inside the jupyter lab notebook:
JupyterLab now prefers a model where arbitrary javascript is no longer allowed to be embedded in a cell's output, which is how many interactive Jupyter Notebook modules used to work. They now ask that modules with interactivity create a JupyterLab extension.
ipywidgets provides #jupyter-widgets/jupyterlab-manager extension which satisfies this requirement.
When using ipywidgets 7.6 or newer in JupyterLab 3.0 or newer you do not need to do anything: it is installed by default. You can check if this is installed by running:
jupyter labextension list
which should include a line like:
#jupyter-widgets/jupyterlab-manager v3.0.0 enabled OK (python, jupyterlab_widgets)
If you are using JupyterLab 1 or 2 (or old version of ipywidgets) you need to install this extension manually by running this on your command line (which assumes you already have NodeJS installed):
jupyter labextension install #jupyter-widgets/jupyterlab-manager
I had the same pbm, and tried this solution (hope it can help others):
The jupyter labextension install #jupyter-widgets/jupyterlab-manager gave this kind of error in my case:
> /Users/user/.nvm/versions/node/v8.7.0/bin/npm pack #jupyter-widgets/jupyterlab-manager
jupyter-widgets-jupyterlab-manager-0.35.0.tgz
Errored, use --debug for full output:
ValueError:
"#jupyter-widgets/jupyterlab-manager#0.35.0" is not compatible with the current JupyterLab
Conflicting Dependencies:
JupyterLab Extension Package
>=0.15.4-0 <0.16.0-0 >=0.16.0-0 <0.17.0-0 #jupyterlab/application
>=1.1.4-0 <2.0.0-0 >=2.0.0-0 <3.0.0-0 #jupyterlab/services
>=0.15.4-0 <0.16.0-0 >=0.16.0-0 <0.17.0-0 #jupyterlab/rendermime
>=0.15.4-0 <0.16.0-0 >=0.16.0-0 <0.17.0-0 #jupyterlab/notebook
Then, what I did is to use a previous version 0.34 instead of 0.35:
jupyter labextension install #jupyter-widgets/jupyterlab-manager#0.34
In fact, according to this, sometime teams get time to consider the last version.
UP (according to comments):
You can check jupyter lab --version and find match on its version compatibility.
And it works now !
Had the same issue, and what worked for me today was running the 'clean' command, as mentioned here: https://ipywidgets.readthedocs.io/en/latest/user_install.html#installing-the-jupyterlab-extension
So:
jupyter lab clean
jupyter labextension install #jupyter-widgets/jupyterlab-manager
And that got it working right for me just now.
Note: most of the above answers are outdated (as of july 19 2021). It should be a lot more seamless with the latest versions of these packages. However, in 2021 I was having an issue rendering panel widgets in jupyterlab hosted on jupyterhub and came across this post. I tried a few of these answers at first but none of them worked. After digging into some of the libraries, I found the following:
jupyter labextension install #jupyter-widgets/jupyterlab-manager is no longer required as of ipywidgets==7.6 and jupyterlab>=3.0. source. If you're on the latest version of jupyterlab, you should just need to install ipywidgets and the extension will be enabled automatically as long as widget extension authors also follow some steps.
The main change in this release is that installing ipywidgets 7.6.0 will now automatically enable ipywidgets support in JupyterLab 3.0—a user has no extra JupyterLab installation step and no rebuild of JupyterLab, nor do they need Node.js installed. Simply install the python ipywidgets package with pip (pip install ipywidgets==7.6.0) or conda/mamba (conda install -c conda-forge ipywidgets=7.6.0) and ipywidgets will automatically work in classic Jupyter Notebook and in JupyterLab 3.0.
panel has also followed suit and bundled the necessary extensions in the pyviz_comms package, so theoretically everything should have been included for my case. source
In the classic Jupyter notebook environment and JupyterLab, first make sure to load the pn.extension(). Panel objects will then render themselves if they are the last item in a notebook cell. For versions of jupyterlab>=3.0 the necessary extension is automatically bundled in the pyviz_comms package, which must be >=2.0.
The answer to my problem turned out to be that I was installing panel after building the jupyterlab server through jupyterhub. (e.g. for a specific notebook, a user was running !pip install panel). This is where I get a little fuzzy since I'm not sure why this doesn't work, given that ipywidgets is already installed and panel install includes the pre-built jupyterlab extension. However, I was able to fix my issue by instead using an a jupyterlab image to spawn from jupyterhub which had ipywidgets>=7.6 and panel>=0.11.3 (and therefore pyviz_comms>=2.0) pre-installed. After this, panel widgets in jupyterlab on jupyterhub now work. Hope this helps anybody having a similar issue.
I have the same issue as #jtlz2 that none of the above suggestion works for me except #hainm's very specific version combination for jupyter-lab, ipywidgests, and jupyter-widgets/jupyterlab-manager.
Following the initial version numbers listed in this post (https://github.com/jupyter-widgets/ipywidgets/issues/2488#issuecomment-509719214), I tried to find the most updated version combination that works. I list them below, such that one can try it if there is really nothing else working for him/her.
pythonversion=3.8.0
labversion=2.1.5
labmanagerversion=2.0
ipywidgetsversion=7.5.1
nodejsversion=10.13.0
conda create -n lab python=$pythonversion -y
source activate lab
conda install nodejs=$nodejsversion -c conda-forge -y
conda install ipywidgets=$ipywidgetsversion -c conda-forge -y
conda install jupyterlab=$labversion -y -c conda-forge
jupyter-labextension install #jupyter-widgets/jupyterlab-manager#$labmanagerversion
It seems that the version of nodejs plays a key role. Holing everything else equal, if I update nodejsversion to 12.x+ or the latest 14.x, this combination as well as #hainm's combination both fail to make ipywidgets behave normally in Jupyterlab.
Other than the one I listed in the above code cell, below 6 combinations also work for me.
(pythonversion ,labversion ,labmanagerversion ,ipywidgets ,nodejsversion)
(3.7 , 0.34 , 0.37 , 7.4.2 , 10.13)
(3.7 , 1.0 , 1.0 , 7.4.2 , 10.13)
(3.7 , 2.0 , 2.0 , 7.4.2 , 10.13)
(3.8 , 2.0 , 2.0 , 7.4.2 , 10.13)
(3.8 , 2.0 , 2.0 , 7.5.1 , 10.13)
(3.8 , 2.1.5 , 2.0 , 7.5.1 , 10.13)
I was getting a Permission Denied error, so adding sudo to the accepted command helped: sudo jupyter labextension install #jupyter-widgets/jupyterlab-manager.
According to ipywidgets.readthedocs.io documentation (Installing the JupyterLab Extension), for "JupyterLab" do the following steps in "Anaconda Prompt".
Step 1
conda install -c conda-forge nodejs
Step 2
jupyter labextension install #jupyter-widgets/jupyterlab-manager
None of the other answers worked to me. It all seems to be down to version compatibility. Finally got it working - see below.
All credit to #hainm on github (original link: https://github.com/jupyter-widgets/ipywidgets/issues/2488#issuecomment-509719214)
My SO answer on this: https://stackoverflow.com/a/60059786/1021819
Here is a straight copy of that answer:
Leveraging https://github.com/jupyter-widgets/ipywidgets/issues/2488#issuecomment-509719214, in a jupyterlab terminal - running on jupyterhub - execute:
pythonversion=3.7
labversion=0.34.12
labmanagerversion=0.37.4
ipywidgetsversion=7.4.2
conda install ipywidgets=$ipywidgetsversion -c conda-forge -y --override-channels -c main
conda install jupyterlab=$labversion -y -c conda-forge --override-channels -c main
jupyter-labextension install #jupyter-widgets/jupyterlab-manager#$labmanagerversion
At this point a jupyter lab clean; jupyter lab build might be of interest.
Then in a .ipynb notebook running in the same jupyterlab window, hit the restart kernel button.
IMPORTANT: Don't forget to also REFRESH the browser page - or all efforts will have been in vain . :\
Then execute the example:
from ipywidgets import interact
#interact(x=(0, 100, 10))
def p(x=50):
pass
I never thought I would live to see the day but - hey presto - the widget finally appears!
The sad things are that the setup is extremely sensitive to the installation of other extensions and the combination of compatible versions is very specific.
Besides everything else, make sure that your ipywidgets are installed in the same conda environment as jupyterlab.
Here is my story (ipywidgets 7.7.0, jupyterlab 3.2.5 installed via conda inside docker):
Running dockerized jupyterlab in base conda environment
Created new conda environment, install ipykernel, make it visible to jupyterlab, install ipywidgets
Switch to new kernel, now jupyterlab recognized ipywidgets as installed, but widgets are not working (only displays text widget description), which is confusing
Solution:
Install ipywidgets in the same conda environment as jupyterlab
Disclaimer: My answer may not be applicable to the original question, since the author did not use separate conda environment. But it can be useful for others facing similar problem.
If you're on linux and you'd rather avoid conda entirely, and use virtual envs (venvs) to keep python happy, AND you happen to be using an 'older'/LTS Debian based OS, which may not have upto date nodejs: Ie, Ubuntu 16.04 LTS, which doesn't have a node but rather nodejs (node belongs to another package, and the 'legacy nodejs' version is too old), then read on.
This is a little more complicated to setup, but much easier to maintain long-term than conda is. (you can always just mk a new venv for a new project, without breaking your old projects).
Main points are:
use PPA's to get fresh versions of the things you need
Use virtualenvwrapper so you can:
use up-to-date python3
avoid messing up your 'pip install''s
avoid getting the system package manager confused
also easily work with people with different versions of python
follow python Best Practise
easily have different venvs which might have old or incompatible python and pip packages.
Use Nodejs binary distributions
need node.js version "10.x" for jupyterlab widgets
allows using the system's package manager to keep nodejs fresh
will be maintained and available as long as LTS's are
So, all actual steps (these were tested to work on Linux Mint 18.3 Sylvia, which is basically compatible with ubuntu xenial aka Ubuntu 16.04 LTS. Differences will arise mostly in nodejs, read the readme in the github link above to solve for other OS):
Get an admin to do (or do yourself if you can sudo):
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install -y python3.8 python3.8-dev python3.8-distutils python3-pip python3-venv
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
Then, as your own user, you can complete the rest of the steps:
pip3 install --user virtualenv virtualenvwrapper
mkdir ~/.envs
You'll then want to add the following to the end of your .bashrc :
export PATH=~/.local/bin:$PATH
export WORKON_HOME=~/.envs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source ~/.local/bin/virtualenvwrapper.sh
At this point, make a new shell, and you will be able to run the rest of the setup, actually installing jupyterlab:
mkvirtualenv -p python3.8 jupenv
pip install jupyter matplotlib pandas ipympl tqdm
jupyter labextension install #jupyter-widgets/jupyterlab-manager
Now you're done.
To open/use jupyter, you want (because of the venv I've called jupenv above, you can name it as you like in that mkvirtualenv line):
workon jupenv
jupyter lab
Otherwise, I had no end of hell trying to get nodejs to work with outdated ubuntu packages. Sometimes it would work, for a few restarts, and then fail. Other times it would just keep giving me the same missing widgets, or sometimes little lines of junk js code.
Virtualenvs are well worth using, especially when you start using python seriously, and working with others who may use different versions / different sets of pip packages. VirtualEnvWrapper makes this pretty painless.
The basic point is that everything you 'pip install', even jupyter, ends up being kept cleanly separate (and separate from the system packages), which keeps everything working very nicely.
There are some basic DO's and DON'T's:
DON'T run pip install ... lines without being in a venv
DON'T use pip3 in place of pip within a venv.
DO just use python and not python3 to run within.
DON'T use conda...!
DO know that you can have all your virtualenvs updated at once with:
allvirtualenv pip install -U pip
As for the nodejs binary distribution packages: These are highly recommended where they support your particular OS. They'll be very up-to-date and should present the minimum of trouble.
Please check steps to make it work in Jupyter 3.0 docs
Please check steps to make it work in Jupyter 1 0r 2 docs
After this restart or build the lab to see the changes