Closed ankitgupta1729 closed 4 years ago
Hi @ankitgupta1729 - This config option (CLI version shown here) should do the trick:
--MappingKernelManager.default_kernel_name=practice_applied_ai
Hi @ankitgupta1729 - This config option (CLI version shown here) should do the trick:
--MappingKernelManager.default_kernel_name=practice_applied_ai
@kevin-bates, Thank you for the reply. I have put "MappingKernelManager.default_kernel_name=practice_applied_ai" in the "jupyter_notebook_config.py" file but still it opens a ipynb file in "python3". Should I have to do something else ?
Got a couple of questions first.
jupyter_notebook_config.py
? Since this is a Python script, it's important the CLI entry be written to be used in Python. You may have already done this, and I apologize if so, but I can't tell and this is key information. You should have an entry like this:
c.MappingKernelManager.default_kernel_name = 'practice_applied_ai'
practice_applied_ai
is the configured default kernel name, issue a POST
request to a similar endpoint: http://localhost:8888/api/kernels?token=5558881dae42ac745da1fdbbdf00458f60015e619c96a173
. Since the kernel name is not specified in the request body, the server will use the configured default. You should get a response similar to the following - where I've configured my default kernel name to be 'ir'
:
{
"id": "f4c581ee-54fd-4e54-947f-b04c1ee4ffce",
"name": "ir",
"last_activity": "2020-07-04T15:50:32.202819Z",
"execution_state": "starting",
"connections": 0
}
Hello sir, I have manually edited the jupyter_notebook_config.py
by creating this file using command jupyter notebook --generate-config
in .jupyter
folder from terminal and then opened it using gedit and then uncommented and saved this file. Sorry if I have done wrong. I have tried jupyter notebook --MappingKernelManager.default_kernel_name=practice_applied_ai
and ipython --MappingKernelManager.default_kernel_name=practice_applied_ai
but these are not working and in jupyter_notebook_config.py
file, I saw only "c.MultiKernelManager.default_kernel_name" entry and when I have changed this attribute's value to "practice_applied_ai", nothing happened. So, I edited that file manually.
I open jupyter notebook in browser by running command jupyter notebook
in terminal and when I open any file from that, it opens it in python3 kernel but I want to open it in "practice_applied_ai" kernel though I can change the kernel (there is an option there) but I have to do it everytime.
Sounds like you're doing the right thing.
when I open any file from that, it opens it in python3 kernel
If you're opening existing notebook files, the kernel-name is part of the file's metadata - so it will use that kernel. I'm not sure how to trigger the use of the "default kernel" other than from the REST API I described previously. The Notebook and Lab UIs require the user to select a kernel when creating notebooks and that selection is from the list of available kernels - which includes the default kernel (among others). You might have the wrong idea about when the default kernel name is used.
Another way to determine your configuration of a default kernel is working is to visit this URL via a web browser: http://localhost:8888/api/kernelspecs
. This is much easier than issuing a POST request as I described previously.
The response to visiting that URL is the set of kernelspec information. The first portion of which is the name of the default kernel. Again, you'll see here the the 'ir' kernel is (now) configured as my default:
{
"default": "ir",
"kernelspecs": {
"python3": {
"name": "python3",
"spec": {
"argv": [
"/opt/anaconda3/envs/elyra-dev/bin/python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"env": {},
"display_name": "Python 3",
"language": "python",
"interrupt_mode": "signal",
"metadata": {}
},
"resources": {
"logo-64x64": "/kernelspecs/python3/logo-64x64.png",
"logo-32x32": "/kernelspecs/python3/logo-32x32.png"
}
},
"ir": {
"name": "ir",
"spec": {
"argv": [
"/Library/Frameworks/R.framework/Resources/bin/R",
"--slave",
"-e",
"IRkernel::main()",
"--args",
"{connection_file}"
],
"env": {},
"display_name": "R",
"language": "R",
"interrupt_mode": "signal",
"metadata": {}
},
"resources": {
"kernel.js": "/kernelspecs/ir/kernel.js",
"logo-64x64": "/kernelspecs/ir/logo-64x64.png"
}
}
}
}
Sir, Thank you so much for the help :)
If you're opening existing notebook files, the kernel-name is part of the file's metadata - so it will use that kernel.
Yes, I checked now. I thought I can open other files which are used with different kernels in the kernel "practice_applied_ai". I did not know that kernel name is part of file's metadata. Now, I understood it.
Glad to hear you're moving forward. I think this issue can be closed.
yes sir, I am closing it now.
I am using ipython 6.4.0 on ubuntu 20.04 and using
jupyter kernelspec list
, I found, there are 2 kernels :When I open any .ipynb file, it directly opens in "python3" but I want to open it in "practice_applied_ai" because I created virtual environment practice_applied_ai and only in this kernel I can import Tensorflow 2.2.0 for my work.
My question is, Is there any way to change my default kernel without removing any kernel ?