AaronC81 / ipython-auto-import

:inbox_tray: Automatically import a Python library in IPython when you forget to import it
MIT License
55 stars 3 forks source link

Installation instructions returns error on Fedora 24 iPython 3.2.1 Python 2.7.12 #11

Closed lordlabakdas closed 8 years ago

lordlabakdas commented 8 years ago

Environment details:


I followed the installation instructions as below

$ sudo pip install colorama
$ git clone https://github.com/OrangeFlash81/ipython-auto-import.git
$ python install.py

When I try running iPython, I get the below error

$ ipython
[TerminalIPythonApp] ERROR | Exception while loading config file /home/siddharth/.ipython/profile_default/ipython_config.py
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/IPython/config/application.py", line 515, in _load_config_files
    config = loader.load_config()
  File "/usr/lib/python2.7/site-packages/IPython/config/loader.py", line 437, in load_config
    self._read_file_as_dict()
  File "/usr/lib/python2.7/site-packages/IPython/config/loader.py", line 490, in _read_file_as_dict
    py3compat.execfile(conf_filename, namespace)
  File "/usr/lib/python2.7/site-packages/IPython/utils/py3compat.py", line 217, in execfile

    builtin_mod.execfile(filename, *where)
  File "/home/siddharth/.ipython/profile_default/ipython_config.py", line 2, in <module>
    c.InteractiveShellApp.exec_lines.append("%load_ext import_wrapper")
NameError: name 'c' is not defined
Python 2.7.12 (default, Jul 18 2016, 10:55:51)
Type "copyright", "credits" or "license" for more information.

IPython 3.2.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details

My ipython_config.py contains only the line c.InteractiveShellApp.exec_lines.append("%load_ext import_wrapper") and I also noticed that import_wrapper.py copied to the ~/.ipython/extensions folder.

Is there something I am missing?

AaronC81 commented 8 years ago

Your version of IPython is an older one which I haven't tested the library on. Also, the library is designed for Python 3 and hasn't been tested on Python 2, although this might not affect it depending on how IPython runs extensions.

First, try adding c = get_config() to the top of ipython_config.py. If that doesn't work, try updating your IPython to the latest version of IPython 4 or 5.

lordlabakdas commented 8 years ago

Adding c = get_config() to top of ipython_config.py worked.

Thank you!

AaronC81 commented 8 years ago

Thanks for letting me know. I'll see if I can add a version check which does this automatically.