[英]How to launch Jupyter Notebook with python command line flags?
I want to disable hash randomization for a particular Jupyter notebook.我想为特定的 Jupyter 笔记本禁用 hash 随机化。 For a regular script, I do this via the
python -R
flag.对于常规脚本,我通过
python -R
标志执行此操作。 How can I achieve the same thing when running jupter-notebook
?运行
jupter-notebook
时如何实现相同的目标?
Of course I can achieve this particular goal via setting the PYTHONHASHSEED
environmental variable but I would like to do it via the flag since it is more flexible.当然,我可以通过设置
PYTHONHASHSEED
环境变量来实现这个特定目标,但我想通过标志来实现,因为它更灵活。
It can be done by either editing the kernel.json
file or registering new kernel with changed kernel.json
file. It can be done by either editing the
kernel.json
file or registering new kernel with changed kernel.json
file.
kernel.json
contains argv
attribute that essentially a command to run python. kernel.json
包含argv
属性,该属性本质上是运行 python 的命令。
{
"argv": [
"python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}
kernel.json
filekernel.json
文件You can find your kernel.json
by running:您可以通过运行以下命令找到您的
kernel.json
:
→ jupyter kernelspec list
Available kernels:
python3 /home/user/.local/share/virtualenvs/jupyter/share/jupyter/kernels/python3
You can edit it to your liking.您可以根据自己的喜好对其进行编辑。
You can use the command from previous solution to find the existing kernel.json
您可以使用先前解决方案中的命令来查找现有的
kernel.json
then install the new kernel:然后安装新的 kernel:
jupyter kernelspec install /home/user/.local/share/virtualenvs/jupyter/share/jupyter/kernels/python3 --name=python3_custom --user
Find your python3_custom
location with找到您的
python3_custom
位置
jupyter kernelspec list
and edit the kernel.json
there并在那里编辑
kernel.json
Jupyterlab kernel docsJupyterlab kernel 文档
registering kernels in ipython/jupyter notebook - kernel.json在 ipython/jupyter 笔记本中注册内核 - kernel.json
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.