Reputation: 41248
I want to disable hash randomization for a particular Jupyter notebook. For a regular script, I do this via the python -R
flag. How can I achieve the same thing when running 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.
Upvotes: 0
Views: 1644
Reputation: 4765
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.
{
"argv": [
"python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python"
}
kernel.json
fileYou can find your kernel.json
by running:
→ 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
then install the new kernel:
jupyter kernelspec install /home/user/.local/share/virtualenvs/jupyter/share/jupyter/kernels/python3 --name=python3_custom --user
Find your python3_custom
location with
jupyter kernelspec list
and edit the kernel.json
there
registering kernels in ipython/jupyter notebook - kernel.json
Upvotes: 2