Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Python import in ipython profile config #1835

Closed
EntilZha opened this issue Jun 1, 2012 · 2 comments
Closed

Use Python import in ipython profile config #1835

EntilZha opened this issue Jun 1, 2012 · 2 comments
Milestone

Comments

@EntilZha
Copy link

EntilZha commented Jun 1, 2012

I am trying to accomplish setting up a profile that will automatically import all the files I reload every time I start working on my project. For example I have a module that from ipython i can import doing this:

from foo import *

I created a new profile for ipython and added the following

comments

c = get_config()
from CrossMatch import *

more comments

When I try to run ipython with my profile I get this error.

[TerminalIPythonApp] Exception while loading config file /home/myname/.ipython/profile_MyProf/ipython_config.py
Traceback (most recent call last):
File "/home/myname/opt/epd/lib/python2.7/site-packages/IPython/config/application.py", line 440, in load_config_file
config = loader.load_config()
File "/home/myname/opt/epd/lib/python2.7/site-packages/IPython/config/loader.py", line 268, in load_config
self._read_file_as_dict()
File "/home/myname/opt/epd/lib/python2.7/site-packages/IPython/config/loader.py", line 321, in _read_file_as_dict
py3compat.execfile(conf_filename, namespace)
File "/home/myname/opt/epd/lib/python2.7/site-packages/IPython/utils/py3compat.py", line 175, in execfile
builtin.execfile(filename, *where)
File "/home/myname/.ipython/profile_MyProf/ipython_config.py", line 5, in
from foo import *
ImportError: No module named foo

Thanks

@bfroehle
Copy link
Contributor

bfroehle commented Jun 1, 2012

You probably want to instead put the statement inside of exec_lines.

For example, from my ipython_config.py:

# lines of code to run at IPython startup.
c.InteractiveShellApp.exec_lines = [
    'from __future__ import division',
    'import io, os, sys, re, time',
]

@EntilZha
Copy link
Author

EntilZha commented Jun 1, 2012

Thanks, worked perfectly. Still new to ipy but love it.

@EntilZha EntilZha closed this as completed Jun 1, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants