我想禁用randomization of Python's hash function。根据该线程(Unable to see or modify value of PYTHONHASHSEED through a module),在运行时通过设置~ (user folder)
~/Documents
~/Documents/useanimal
~/Documents/useanimal/UseDog.java
~/Downloads
~/Downloads/animal
~/Downloads/animal/Dog.java
来设置PYTHONHASHSEED不起作用。运行Jupyter Notebook时如何将PYTHONHASHSEED设置为固定值?
答案 0 :(得分:3)
您可以尝试修改kernel.json
并添加行"env": {"PYTHONHASHSEED":"0"}
。
该文件位于您的python文件夹或虚拟环境中,位于:
[venv|python-folder]/share/jupyter/kernels/python3/kernel.json
kernel.json:
{
"argv": [
"python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"language": "python",
"env": {"PYTHONHASHSEED":"0"}
}
那为我解决了这个问题。
答案 1 :(得分:-1)
尝试添加
%env PYTHONHASHSEED = 0
输入您的代码。 详细信息:
https://ipython.readthedocs.io/en/stable/interactive/magics.html?highlight=env#magic-env