Closed caethan closed 7 years ago
Works for me on 5.0.0 -- thanks @caethan!
Seem's that travis is not happy.
@caethan Thanks for the solution. I've tell you how to change travis to pass the tests.
@caethan Thanks for the solution. This works perfectly for me!
Fixed the travis build. Thanks for the fixes, @tguillemot !
Thanks @caethan. It would be great to see this merged and released on PyPI soon.
How does this compare to #68?
@cancan101: Looks like #68 is a better approach - no need to include IPython as a specific dependency there. I'd use that one (assuming it works, haven't tested it myself).
This does not work for me on IPython 5.1 & Jupyter NB 4.2.2:
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/IPython/core/extensions.py in _call_load_ipython_extension(self, mod)
130 def _call_load_ipython_extension(self, mod):
131 if hasattr(mod, 'load_ipython_extension'):
--> 132 mod.load_ipython_extension(self.shell)
133 return True
134
/Users/esafak/Library/Python/3.5/lib/python/site-packages/line_profiler.py in load_ipython_extension(ip)
370
371 return return_value
--> 372
373
374 def load_ipython_extension(ip):
AttributeError: 'ZMQInteractiveShell' object has no attribute 'define_magic'
@esafak Sure looks like you're using the master branch without this bug fix.
@caethan I'm agree with you. #68 is a better solution indeed.
self
so functions like parse_options
don't exist unless the magic function extends the Magics
class. Therefore, this is the correct fix.Throwing in my support for this fix. I ran into this failure when updating the IPython section of my book (where I use line_profiler
)
@patricksnape: Thanks for checking #68!
Is there anything preventing this from being merged?
@rkern?
does not work for me on iPython 5.1 either:
IPython 5.1.0 -- An enhanced Interactive Python. ... [TerminalIPythonApp] WARNING | Error in loading extension: line_profiler_ext Check your config files in /Users/grigsbye/.ipython/profile_default Traceback (most recent call last): File "/usr/local/lib/python3.5/site-packages/IPython/core/shellapp.py", line 246, in init_extensions self.shell.extension_manager.load_extension(ext) File "/usr/local/lib/python3.5/site-packages/IPython/core/extensions.py", line 85, in load_extension if self._call_load_ipython_extension(mod): File "/usr/local/lib/python3.5/site-packages/IPython/core/extensions.py", line 132, in _call_load_ipython_extension mod.load_ipython_extension(self.shell) File "/Users/grigsbye/.ipython/extensions/line_profiler_ext.py", line 4, in load_ipython_extension ip.define_magic('lprun', line_profiler.magic_lprun) AttributeError: 'TerminalInteractiveShell' object has no attribute 'define_magic'
@espg Have you tried installing the branch from this PR? That error message suggests you have the current version of line_profiler installed, which won't work on 5.0 or greater.
What needs to be done to get this merged? Anything we can help with?
@danielballan I ran:
~ ➤ pip3 install git+https://github.com/rkern/line_profiler.git
Collecting git+https://github.com/rkern/line_profiler.git Cloning https://github.com/rkern/line_profiler.git to /tmp/pip-is2n9c7m-build Installing collected packages: line-profiler Running setup.py install for line-profiler ... done Successfully installed line-profiler-1.0
to install the branch... running ipython gives the errors in my other post. Note that this is on iPython 5.1.0 and python 3.5.2
@espg Try the following to install the patched version available in this PR:
pip3 install --upgrade git+https://github.com/caethan/line_profiler
@gforsyth no dice:
~ ➤ pip3 install --upgrade git+https://github.com/caethan/line_profiler Collecting git+https://github.com/caethan/line_profiler Cloning https://github.com/caethan/line_profiler to /tmp/pip-dkkb048l-build Installing collected packages: line-profiler Found existing installation: line-profiler 1.0 Uninstalling line-profiler-1.0: Successfully uninstalled line-profiler-1.0 Running setup.py install for line-profiler ... done Successfully installed line-profiler-1.0 ~ ➤ ipython Python 3.5.2 (default, Sep 29 2016, 18:13:17) Type "copyright", "credits" or "license" for more information.
IPython 5.1.0 -- 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. [TerminalIPythonApp] WARNING | Error in loading extension: line_profiler_ext Check your config files in /Users/grigsbye/.ipython/profile_default Traceback (most recent call last): File "/usr/local/lib/python3.5/site-packages/IPython/core/shellapp.py", line 246, in init_extensions self.shell.extension_manager.load_extension(ext) File "/usr/local/lib/python3.5/site-packages/IPython/core/extensions.py", line 85, in load_extension if self._call_load_ipython_extension(mod): File "/usr/local/lib/python3.5/site-packages/IPython/core/extensions.py", line 132, in _call_load_ipython_extension mod.load_ipython_extension(self.shell) File "/Users/grigsbye/.ipython/extensions/line_profiler_ext.py", line 4, in load_ipython_extension ip.define_magic('lprun', line_profiler.magic_lprun) AttributeError: 'TerminalInteractiveShell' object has no attribute 'define_magic'
Hey @espg -- it looks like pip3
isn't pointing to the python install where ipython lives. I don't want to pollute this thread with a bunch of troubleshooting but if you want to drop into https://tlk.io/line_profiler I'm happy to walk you through figuring it out.
@espg That error message ("no attribute 'define_magic') suggests that your ipython
is still not finding the version of the code in this PR, which replaces define_magic
with the new IPython magics API. Perhaps your ipython
and your pip
are in different environments.
I second @jakirkham's offer to help -- I'd be willing to do the release if that helps get this out the door and restore compatibility with IPython stable.
Talked with @espg and found the problem: He had a custom extension that tried to load in the magic command using define_magic. Fixed it to use the new method. Apparently scikit-learn suggested this method in some of their documentation, so I should submit a pull request to fix it once this pull request gets merged.
Possibly someone should ask @rkern for access to make new releases - or even maintain a fork, if Robert has gone awol.
Talked to @rkern offline and he's going to transfer maintenance responsibility over to me, so we should be able to get this released properly before too long.
Thanks @caethan :-)
Merged in here - will announce on this thread once I get maintainer access to PyPi and 2.0 is released there.
2.0 is released on PyPi with this fix. Enjoy and be merry!
:+1: this has bit me today and ended up here only to find the interwebs haven't caught up with this fix.
thank you!
Replaces the depreciated ip.define_magic() method with ip.register_magics() and some modifications to handle the different API required.
Also tested with IPython 4.1.1. I don't know how far back the ip.register_magics() method goes, so I'm not sure how far back it's compatible.
Edit: Apparently the new API was included as far back as 0.13, and the old API was finally removed in 5.0. So removing support for the old API entirely is pretty unlikely to cause problems.