2

I'm using VSCode version 1.105.0. I want to run some Python code in Jupyter Notebook. To do this, I need to install ipykernel, which I do after activating venv (pip install ipykernel). Next, I execute the first cell in my .ipynb file, and the following is shown in red below the cell:

Running cells with '.venv (Python 3.13.5)' requires the ipykernel package.
Install 'ipykernel' into the Python environment. 
Command: '"c:/[myDirectory]/.venv/Scripts/python.exe" -m pip install ipykernel -U --force-reinstall'

(I've edited the path to the directory and abbreviated it as \[myDirectory\] for readability here.) Additionally, a pop-up message appears:

Running cells with '.venv (Python 3.13.5)' requires the ipykernel and pip package.

When i want to run the command suggested in the message, nothing seems to be happening (no output on the terminal suggesting that ipykernel is indeed being reinstalled). See below:

(.venv) PS C:/[myDirectory]/.venv/Scripts/python.exe" -m pip install ipykernel -U --force-reinstall
>> 

Additionally, when i go into ./venv/Lib/site-packages I can see both pip and ipykernel there.

Deleting the venv, recreating it and reactivating leads to the same output as described above.

I'd be very thankful for any help.

1

1 Answer 1

2

This is due to a conflict with recent versions of Jupyter. The solution is to use the pre-release version of the Jupyter extension and set up a local server:

1. Install the pre-release version of Jupyter

2. Set up your virtual environment (in the terminal):

.venv\Scripts\activate

python -m pip install --upgrade pip

pip install ipykernel jupyter

3. Start the Jupyter server:

jupyter notebook --no-browser

Copy the full URL that appears (example: `http://localhost:8888/?token=abc123...`)

4. Connect VS Code to the server:

• Open your notebook

• Click on the kernel selector

• Select “Select Another Kernel...” → “Existing Jupyter Server...”

• Paste the full URL (with the token)

• Press Enter

• Select the Python interpreter: .venv\Scripts\python.exe

And it should work now :D

Translated with DeepL.com (free version)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.