Reputation: 41
I created a new conda environment named 'ct' and installed Python 3.10.6, Jupyter Lab, matplotlib and numpy. Also the ipykernel is installed.
VS Code lets me select Python 3.10.6 from 'ct' as interpreter without issues.
But I cannot choose 'ct' as kernel as VS Code only suggests the 'base' kernel from conda. 'base' does not have the desired packages installed which leads to the following error when running this code:
import matplotlib as mat
print(mat.__version__)
error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Untitled-1.ipynb Cell 1 in <cell line: 1>()
----> 1 import matplotlib as mat
2 print(mat.__version__)
ModuleNotFoundError: No module named 'matplotlib'
This is actually totally fine but I don't get why the 'ct' kernel is not showing up in the list when trying to change the kernel.
Also when running jupyter lab in browser from 'ct' environment everything is working as should.
When listing all installed packages in 'ct' in the VS Code terminal all packages show up.
Restarting VS Code and trying with other new conda environments does not help the issue.
Did I somehow miss something?
Upvotes: 2
Views: 10710
Reputation: 30
I had the same problem. Changing the version of the jupyter extension didn't change anything for me, even younger versions.
I managed to fix it by removing VSCode from my machine, and deleting the associated folders on my laptop (.vscode, ...). I installed the system version, I had the user version so far, did the installation from scrach, and finally it worked.
Hope this helps
Upvotes: 0
Reputation: 43
I have found out an alternative. The steps are:
code
command which opens a VSCode.This worked for me after trying several alternatives. A prerequisite is obviously to have the jupyter extension installed in VSCode.
Upvotes: 1
Reputation: 1599
Try this conda install -n meta_ai ipykernel --update-deps --force-reinstall
Somehow it solved my problems.
If it still can't solve your problem, try also opening the directory in VS Code, instead of only the .ipynb file.
Upvotes: 1
Reputation: 2840
I solved this issue by opening the directory in VS Code, instead of only the .ipynb
file.
Upvotes: 1
Reputation: 41
What finally worked out for me was closing VS Code entirely, recreating the environment and creating a new blank notebook in VS Code. Now the kernel shows up and is surprisingly available for all new and old notebooks.
I also found this option in the Jupyter settings in VS Code: https://i.sstatic.net/rcJU6.png
I haven't tried it yet, but it might be helpful to someone experiencing similar issues.
Also Zac's solution above might be super helpful. Thank you for sharing!
Upvotes: 2
Reputation: 372
Switching to the "pre-release" version of the Jupyter extension immediately solved this problem for me.
Upvotes: 2
Reputation: 9199
Obviously, this is not a universal problem.
You can read the docs and recreate the conda environment.
This may also be related to the fact that your conda environment is not activated. Use the command conda activate ct
to activate it.
Upvotes: 0