配置Jupyter默认导入 [英] Configuring Jupyter default imports
本文介绍了配置Jupyter默认导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何告诉Jupyter(控制台和笔记本)默认情况下导入一些Python软件包?我只想使用.jupyter
文件夹
How do I tell Jupyter (console and notebook) to import some Python packages by default? I would like to do this using only the .jupyter
folder
推荐答案
我个人找不到仅使用.jupyter
文件夹的方法.无论如何,您都必须在.ipython
文件夹中指定要在启动时执行的命令:
I personally couldn't find a way to do so only using the .jupyter
folder. You have to specify the commands to be executed on startup in the .ipython
folder anyway:
- 创建
~/.ipython/profile_default/ipython_config.py
(如果不存在) -
添加类似这样的内容:
- Create
~/.ipython/profile_default/ipython_config.py
if it not exists Add something like this:
c = get_config()
c.InteractiveShellApp.exec_lines = [
'import numpy as np\n'
'import scipy as sp\n'
'import matplotlib as plt\n'
]
您还可以在此处指定任何有效的命令,不仅可以导入.
You can also specify any valid commands here, not only imports.
这篇关于配置Jupyter默认导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文