Select python kernel for Jupyter notebook - python

This is a basic beginner question.
I have a python Jupyter notebook, when <Enter><Shift> is used, the focus goes to the top of the screen where the message is Select kernel for 'D:/...' Under this is the message: "Install kernels from the marketplace." There is no other visible message to explain what that means or what I am missing.
Steps to solve.
In one document, it mentioned that VSC should be opened using code from a [conda] environment where python is installed and there is a kernel. This required the following code in my environment
activate conda environment edw
conda activate edw
Next install a kernel
ipython kernel install --name "edw" --user
Verify the kernels
jupyter kernelspec list
result
edw C:\Users\hnelson3\AppData\Roaming\jupyter\kernels\edw
Start VSC
code
Next I open a notebook and put my cursor in a code block.
<Enter><Shift>
The message Select kernel for 'D:/...' appears. What is the next step?
Thanks.

I had that message 'Select kernel for 'D:/...' appearing as well when I first tried to run a jupyter notebook in VS code. Turns out I had to install and enable the jupyter extension (https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter) and the python extension (https://marketplace.visualstudio.com/items?itemName=ms-python.python) as according to these instructions from https://code.visualstudio.com/learn/educators/notebooks:
"You will need to have Python 3 installed on your machine along with the Microsoft Python extension installed from the VS Code Marketplace...
In addition, you need to install the Jupyter Notebooks extension...
Once you have Python and the extensions installed, you will need to activate the Python environment by using the command Python: Select Interpreter from the Command Palette (Ctrl+Shift+P)."

Related

Jupyter Notebook in VS Code is not working

I'm using Ubuntu, installed Vs Code and anaconda. I've also installed python extension in VS Code, which brings Jupyter Notebook extension. Now, whenever I'm trying to run code from the Jupyter extension, its throwing error as if it requires ipykernel.
Now, my conda 'base' environment has already ipykernel. Why cant Jupyter extension look for ipykernel from the current activated environment?
Is there any explicit settings to be made, to make VS Code Jupyter extension use ipykernel from the current active environment? Please provide it.
Click here to switch the environment of Jupyter Notebook.
Possible solution python -m ipykernel install --user --name=conda_env_name

"Failed to find a kernelspec to use for ipykernel launch" error happens when I run on virtual studio

Hi I am using virtual studio and running the command on Jupiter notebook.
But this error happens.
"Failed to find a kernelspec to use for ipykernel launch"
Why can't I execute the command this time?
I had a similar situation. I was trying to switch from Anaconda to VS Code to run jupyter notebooks. Installed the extension for jupyter notebook and every time I tried creating an empty notebook and basic commands failed to run. On the top right corner, I noticed that the kernel just showed Busy. If you click on that it would ask for a kernel.
I was able to get it working after I installed the python extension on vscode.. not sure if this is the best approach though!!
You need to install the Python libraries Jupyter and ipykernel. On my VS Code editor, a prompt came up saying that ipykernel is missing, and clicking the "install" button would solve it.

Installing a ipykernel and running jupyter notebook inside a virtual env - not using conda

I've hit a dead end trying to solve/debug this issue which doesn't seem like it should be that difficult.
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 be able to run launch a jupyter notebook in this environment so that it can pick up all the python packages i've installed and configured for this environment.
As I understand it from the documentation, these are the steps I need to take.
My terminal prompt statement:
(pythonProject) oliver#oliver-u20:~/pythonProject$
commands:
python3 -m pip install ipykernel
python3 -m pip install notebook
python3 -m ipykernel install --user --name pythonProject --display-name "Python (pythonProject)"
jupyter notebook
But when I load jupyter notebook, it only shows python3 under kernels.
I tried outputting
jupyter kernelspec list
And get only the base kernel which suggests from this that it's not finding my kernelspec, but I can't seem to figure from the documentation what i'm supposed to do.
Am I missing something?
Ok so I've solved this.
I think there was an install issue with jupyter.
I tried reproducing this in a completely new project and venv and could get the kernel showing.
In the project and venv where I still couldn't, I noticed a discrepancy in the output of my jupyter --paths
In the working venv I could see under data
/home/oliver/.local/share/jupyter
Which is where the kernels I installed are located.
However in the project that wasn't working there was instead:
/home/oliver/snap/jupyter/6/.local/share/jupyter
I'm guessing this snap path is from how I originally installed jupyter on my Ubuntu via the app store - seemed sensible at the time.
So I uninstalled jupyter, restarted my venv and the jupyter --paths has magically changed so that
/home/oliver/.local/share/jupyter
is present and when I start a jupyter notebook at the command line with
jupyter notebook
I can see all my kernels showing!
I found this quite difficult to debug with the documentation and command help outputs so hope someone else finds this useful.

Jupyter Notebook opens a blank page for all environments except base(root)

I am trying to follow the TensorFlow API documentation. I have done all the steps and activated my tensorflow_gpu environment. In the C:\TensorFlow\models\research\object_detection I typed "jupyter notebook" and it opens me a blank page http://localhost:8889/tree.
I tried to open the Jupyter Notebook in my base(root) and it opens the dashboard but for the other environments it only gives me a blank page.
How can I avoid that? Thank you.
I tried to delete and re-install jupyter notebook for that specific environments. I tried to upgrade and downgrade the version of it. Nothing worked yet.
You can still run the Jupyter Notebook in your base environment and make the notebook run with a different kernel (like if you are running the notebook in a different environment). In order to do so you need to install these packages in all of your environment:
conda install nb_conda nb_conda_kernels ipykernel
By doing so you will be able to see the kernels of all of your environments directly in base.
You will be able to start jupyter notebook in base, and once the notebook is running in your browser you can decide which kernel to use.
In the above picture I started Jupyter Notebook in my base environment, and having installed those packages in all the environments let me run any notebook with any kernel.
NB: My other environments are tf_lite1.13, tf_lite2, tf_night. Root will run the base kernel.

How do I add a python3 kernel to my jupyter notebook?

I installed jupyter notebook along with anaconda python as the only python on my PC (Windows 10). However I recently installed python 3.6.2 and I wonder if I can somehow add it to jupyter so as I can use them changeably.
I remember having both on my other machine when I installed python first and then after that I installed the whole anaconda package with the jupyter notebook (so I had python 3 and python(conda) option for kernels).
So how can I add to jupyter?
To install a Jupyter kernel for a different version of Python, run:
conda create -n py36 'python=3.6' ipykernel # Replace `3.6` with desired version
To enable the newly installed Jupyter kernel in all conda environments, run:
source activate py36
python -m ipykernel install --user
Now, when you start Jupyter from your root environment, you will have the option to choose a different Python kernel when you click on 'Kernel -> Change kernel':
source deactivate
jupyter notebook
For more info, see Installing the IPython kernel.
Simple, just find where the script jupyter-notebook resides, for example ~/.local/bin if you installed it locally.
Then just edit the first line to: #!/usr/bin/python3 will be fine.

Categories

Resources