anntzer / ipython-autoimport

Automagically import missing modules in IPython.
zlib License
58 stars 5 forks source link

Breaks Jupyter Notebook #2

Closed hermit-crab closed 6 years ago

hermit-crab commented 6 years ago

Defined functions fail to lookup variables from the global scope.

screenshot_2018-01-22_06-26-53

Commenting out corresponding line in ipython_config.py file and restarting notebook process helps. %unload_ext ipython_autoimport within the notebook does not help.

Notebook server 5.0.0 and is running on:
Python 3.6.4 (default, Dec 23 2017, 19:07:07) 
[GCC 7.2.1 20171128]
Current Kernel Information:
Python 3.6.4 (default, Dec 23 2017, 19:07:07) 
IPython 6.2.1
Archlinux 4.14.12-1-ARCH
anntzer commented 6 years ago

I can't reproduce (i.e., the given example code "just works" for me) with

Server Information:
You are using Jupyter notebook.

The version of the notebook server is: 5.3.1
The server is running on this version of Python:
Python 3.6.4 (default, Dec 23 2017, 19:07:07) 
[GCC 7.2.1 20171128]

Current Kernel Information:
Python 3.6.4 (default, Dec 23 2017, 19:07:07) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.

I have checked that the extension is loaded (autoimporting works).

Also tried with notebook 5.0.0 which works just as well.

hermit-crab commented 6 years ago

Weird. No idea then. Could be something with my setup. Might check further sometimes if I ever get to it and report back here.

anntzer commented 6 years ago

Would be nice to see whether you can reproduce e.g. with jupyter console and/or ipython instead of jupyter notebook; also, do you have any other extensions active?

hermit-crab commented 6 years ago

Yeeep. Happens in both jupyter console and regular ipython. Was absolutely sure I've checked it before reporting but oh well. Have no other extensions defined in config. Global namespace with and without autoimport preloaded also differ:

# globals().keys()

# without
dict_keys(['__name__', '__doc__', '__package__', '__loader__', '__spec__', '__builtin__', '__builtins__', '_ih', '_oh', '_dh', 'In', 'Out', 'get_ipython', 'exit', 'quit', '_', '__', '___', '_i', '_ii', '_iii', '_i1', 'b', '_i2'])
# with (no variable `b` here which I set with `b = 1`)
dict_keys(['__name__', '__doc__', '__package__', '__loader__', '__spec__', '__builtin__', '__builtins__', '_ih', '_oh', '_dh', 'In', 'Out', 'get_ipython', 'exit', 'quit', '_', '__', '___'])
anntzer commented 6 years ago

Ah. Got it, the issue was fixed at some point between 0.2 (the last release) and master. Can you try installing from git HEAD? I need to cut a new release...

hermit-crab commented 6 years ago

Yep, all good. Thank!

anntzer commented 6 years ago

v0.3 released.