line_profiler (%lprun) also broken from IPython upgrade

651 views
Skip to first unread message

Travis Scrimshaw

unread,
Sep 1, 2016, 10:03:31 AM9/1/16
to sage-devel
I just installed the line profiler because I want to do %lprun, but this is broken in 7.4.beta2 (likely is beta0)

┌────────────────────────────────────────────────────────────────────┐
SageMath version 7.4.beta2, Release Date: 2016-08-26              
Type "notebook()" for the browser-based notebook interface.        
Type "help()" for help.                                            
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Warning: this is a prerelease version, and it may be unstable.    
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
from[SageTerminalApp] WARNING | Error in loading extension: line_profiler
Check your config files in /home/travis/.sage/ipython-5.0.0/profile_default
Traceback (most recent call last):
 
File "/home/travis/sage-build/local/lib/python2.7/site-packages/IPython/core/shellapp.py", line 246, in init_extensions
   
self.shell.extension_manager.load_extension(ext)
 
File "/home/travis/sage-build/local/lib/python2.7/site-packages/IPython/core/extensions.py", line 85, in load_extension
   
if self._call_load_ipython_extension(mod):
 
File "/home/travis/sage-build/local/lib/python2.7/site-packages/IPython/core/extensions.py", line 132, in _call_load_ipython_extension
    mod
.load_ipython_extension(self.shell)
 
File "/home/travis/sage-build/local/lib/python2.7/site-packages/line_profiler.py", line 372, in load_ipython_extension
    ip
.define_magic('lprun', magic_lprun)
AttributeError: 'SageTerminalInteractiveShell' object has no attribute 'define_magic'

Volker and IPython upgrade people, please fix this (and %attach).

Travis

VulK

unread,
Sep 1, 2016, 10:10:14 AM9/1/16
to sage-...@googlegroups.com
these might be useful:

https://github.com/rkern/line_profiler/issues/61
https://github.com/rkern/line_profiler/issues/62
https://github.com/rkern/line_profiler/pull/65
https://github.com/rkern/line_profiler/pull/68

Best
S.


* Travis Scrimshaw <tsc...@ucdavis.edu> [2016-09-01 07:03:31]:

> I just installed the line profiler because I want to do %lprun, but
> this is broken in 7.4.beta2 (likely is beta0)
> ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
> â SageMath version 7.4.beta2, Release Date: 2016-08-26 Â Â Â Â Â
> Â Â â
> â Type "notebook()" for the browser-based notebook interface. Â Â Â
> Â â
> â Type "help()" for help. Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
> Â Â Â Â Â Â Â â
> ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
> ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
> â Warning: this is a prerelease version, and it may be unstable. Â Â
> â
> ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
> from[SageTerminalApp] WARNING | Error in loading extension:
> line_profiler
> Check your config files in
> /home/travis/.sage/ipython-5.0.0/profile_default
> Traceback (most recent call last):
> Â File
> "/home/travis/sage-build/local/lib/python2.7/site-packages/IPython/core
> /shellapp.py", line 246, in init_extensions
> Â Â self.shell.extension_manager.load_extension(ext)
> Â File
> "/home/travis/sage-build/local/lib/python2.7/site-packages/IPython/core
> /extensions.py", line 85, in load_extension
> Â Â if self._call_load_ipython_extension(mod):
> Â File
> "/home/travis/sage-build/local/lib/python2.7/site-packages/IPython/core
> /extensions.py", line 132, in _call_load_ipython_extension
> Â Â mod.load_ipython_extension(self.shell)
> Â File
> "/home/travis/sage-build/local/lib/python2.7/site-packages/line_profile
> r.py", line 372, in load_ipython_extension
> Â Â ip.define_magic('lprun', magic_lprun)
> AttributeError: 'SageTerminalInteractiveShell' object has no attribute
> 'define_magic'
> Volker and IPython upgrade people, please fix this (and %attach).
> Travis
>
> --
> You received this message because you are subscribed to the Google
> Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [1]sage-devel+...@googlegroups.com.
> To post to this group, send email to [2]sage-...@googlegroups.com.
> Visit this group at [3]https://groups.google.com/group/sage-devel.
> For more options, visit [4]https://groups.google.com/d/optout.
>
> References
>
> 1. mailto:sage-devel+...@googlegroups.com
> 2. mailto:sage-...@googlegroups.com
> 3. https://groups.google.com/group/sage-devel
> 4. https://groups.google.com/d/optout

Brett Olsen

unread,
Oct 20, 2016, 6:06:58 PM10/20/16
to sage-devel
This was a known bug in line_profiler that is fixed with the 2.0 release.  Try upgrading to line_profiler==2.0 and let us know if there's still a problem.

Travis Scrimshaw

unread,
Oct 21, 2016, 1:49:17 AM10/21/16
to sage-devel


On Thursday, October 20, 2016 at 5:06:58 PM UTC-5, Brett Olsen wrote:
This was a known bug in line_profiler that is fixed with the 2.0 release.  Try upgrading to line_profiler==2.0 and let us know if there's still a problem.

Yes, upgrading fixed it. Thank you!

Best,
Travis
 

John H Palmieri

unread,
Nov 4, 2016, 4:35:32 PM11/4/16
to sage-devel

For anyone else who is interested, here is what I did to get this to work on OS X:

  sage -i openssl   # since pip complains about no ssl module in the Python build
  sage -f python2

Then

  sage -pip install line_profiler

installs a version of line_profiler, specific to OS X, which is broken as far as I can tell. At least it didn't work for me; if I tried %lprun at the Sage command line, it would respond like this:

  sage: %lprun?
  Object `%lprun` not found.
  sage: %lprun
  ERROR:root:Line magic function `%lprun` not found.

So I went to https://pypi.python.org/pypi/line_profiler/, downloaded the source code as a tarball, and did

  sage -pip install /path/to/tarball

Now it works.

--
John

Reply all
Reply to author
Forward
0 new messages