在IPython中重新加载模块不起作用

时间:2016-06-05 07:08:01

标签: ipython jupyter

我的.ipython_kernel_config.py设置如下:

c.InteractiveShellApp.extensions = ['autoreload']   
c.InteractiveShellApp.exec_lines = ['%autoreload']

# Run these commands on startup
c.InteractiveShellApp.exec_lines = [
                                    # imports
                                    "import pandas as pd",
                                    "import numpy as np",
                                    "from scipy import stats",
                                    "import matplotlib.pyplot as plt",
                                    "import statsmodels.api as sm",
                                    "import os",

                                    # Set options
                                    "pd.set_option('display.width', 200)",
                                    "pd.set_option('display.max_rows', 200)",

                                    # Change working directory and import from everything.py
                                    "os.chdir('/home/farasi/py_modules')",
                                    "from everything import *",

                                    # Set variables
                                    "data = '/home/farasi/data/entries.xlsx'",
                                    "results = '/home/farasi/data/results.xlsx'"
                                    ]

除了自动加载不起作用外,.ipython_kernel_config.py文件中的设置似乎都运行正常。我究竟做错了什么?我在Ubuntu 16.04 32位上使用Jupyter

1 个答案:

答案 0 :(得分:0)

查看文档:{​​{3}}

  

%自动重

     

自动现在重新加载所有模块(%aimport排除的模块除外)。

您应该使用%autoreload 2,这将在需要时重新加载代码。