我需要制作一个ipython会话的截屏视频,并且为了避免混淆观众,我想禁用warnings.warn来自不同包的调用发出的所有警告.有没有办法配置ipythonrc文件来自动禁用所有这些警告?
我在jupyter笔记本中收到这个警告.
/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:10: DeprecationWarning: object of type <class 'float'> cannot be safely interpreted as an integer.
# Remove the CWD from sys.path while we load stuff.
/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:11: DeprecationWarning: object of type <class 'float'> cannot be safely interpreted as an integer.
# This is added back by InteractiveShellApp.init_path()
Run Code Online (Sandbox Code Playgroud)
这很烦人,因为它出现在我做的每一次跑步中:
我该如何修复或禁用它?
我正在 Jupyter Notebook 和我正在使用的库 (PyNN) 中运行 Python 脚本,会产生大量 stderr 输出,从而减慢代码速度并填满内存。我尝试在单元格的开头使用 %%capture 但没有任何改变,并且输出保持不变。
任何提示表示赞赏。谢谢