问题描述
我想禁用。根据此主题(无法查看或修改PYTHONHASHSEED的值),则在运行时通过设置 os.environ ['PYTHONHASHSEED']
来设置PYTHONHASHSEED不起作用。运行Jupyter Notebook时如何将PYTHONHASHSEED设置为固定值?
I want to disable the randomization of Python's hash function. According to this thread (Unable to see or modify value of PYTHONHASHSEED through a module), setting PYTHONHASHSEED by setting os.environ['PYTHONHASHSEED']
at runtime does not work. How can I set PYTHONHASHSEED to a fixed value when I run Jupyter Notebook?
推荐答案
您可以尝试修改 kernel.json
并添加行 env:{ PYTHONHASHSEED: 0}
。
文件位于您的python文件夹或虚拟环境中,位于:
You can try to modify the kernel.json
and add the line "env": {"PYTHONHASHSEED":"0"}
.The file is located in your python-folder or virtual environment at:
[venv|python-folder]/share/jupyter/kernels/python3/kernel.json
kernel.json:
kernel.json:
{
"argv": [
"python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python",
"env": {"PYTHONHASHSEED":"0"}
}
那为我解决了这个问题。
That solves the issue for me.
这篇关于有没有办法为Jupyter Notebook会话设置PYTHONHASHSEED?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!