name 'get_config' is not defined

2019-02-16 15:04发布

when i am working with ipython notebook, i want to run a notebook server. I followed the official tutorial However, when I want to obtain the get_config() function as said in the tutorial, I come across with the name get_config is not defined problem. I searched the internet and found the page . However, there is no ~/.ipython/profile_default/ipython_config.py file in my ubuntu 12.04 system. What can I do to solve the problem?

1条回答
Luminary・发光体
2楼-- · 2019-02-16 15:41

Paul Ivanov stated in the forum post:

get_config is available only inside the configuration files at load time.

So you can only use get_config in configuration files, not in an ipython session.

You basically have two options:

If you only want to make temporary changes, you can use the %config magic. But note that changes are lost after you exit the session.

The documentation says:

At present, this only affects the current session - changes you make to config are not saved anywhere. Also, some options are only read when IPython starts, so they can’t be changed like this.

The second option is to create a new profile. (see ipython profile help). Each profile comes with its own config files. You can find the files by executing:

ls $(ipython locate profile <your-profile-name>)

You can add your configuration options to a specific *_config.py file.

For a further reading, see ipython's config intro.

查看更多
登录 后发表回答