Cannot plot in both notebook and terminal mode

164 views
Skip to first unread message

Miguel Yorro

unread,
Sep 8, 2014, 11:03:31 PM9/8/14
to sage-s...@googlegroups.com
Hi! I'm using Craig Finch Sage Beginner's Guide to learn to use Sage. However, when I ran the following code (both in the notebook and terminal mode)

sage: var('x')
x
sage
: sinc(x) = sin(x)/x
sage
: plot(sinc, (x, -10, 10))


the following error appeared (terminal mode)

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-04a086d308e2> in <module>()
----> 1 plot(sinc, (x, -Integer(10), Integer(10)))


/home/myorro/Sage/local/lib/python2.7/site-packages/IPython/core/displayhook.pyc in __call__(self, result)
   
250             self.start_displayhook()
   
251             self.write_output_prompt()
--> 252             format_dict, md_dict = self.compute_format_data(result)
   
253             self.write_format_data(format_dict, md_dict)
   
254             self.update_user_ns(result)


/home/myorro/Sage/local/lib/python2.7/site-packages/IPython/core/displayhook.pyc in compute_format_data(self, result)
   
152
   
153         """
--> 154         return self.shell.display_formatter.format(result)
    155
    156     def write_format_data(self, format_dict, md_dict=None):


/home/myorro/Sage/local/lib/python2.7/site-packages/IPython/core/formatters.pyc in format(self, obj, include, exclude)
    198             md = None
    199             try:
--> 200                 data = formatter(obj)
    201             except:
    202                 # FIXME: log the exception


/home/myorro/Sage/local/lib/python2.7/site-packages/sage/misc/displayhook.pyc in __call__(self, obj)
    518             sage: fmt.set_display('simple')
    519         """

--> 520         if self.try_format_graphics(obj):
   
521             return ''
   
522         s = self.try_format_obj(obj)


/home/myorro/Sage/local/lib/python2.7/site-packages/sage/misc/displayhook.pyc in try_format_graphics(self, obj)
   
415         from sage.structure.sage_object import SageObject
   
416         if isinstance(obj, SageObject) and hasattr(obj, '_graphics_'):
--> 417             return obj._graphics_()
   
418         return False
   
419


/home/myorro/Sage/local/lib/python2.7/site-packages/sage/plot/graphics.pyc in _graphics_(self)
   
822              Graphics object consisting of 0 graphics primitives]
   
823         """
--> 824         self.show()
    825         return True
    826


/home/myorro/Sage/local/lib/python2.7/site-packages/sage/misc/decorators.pyc in wrapper(*args, **kwds)
    469             kwds[self.name + "
options"] = suboptions
    470
--> 471             return func(*args, **kwds)
    472
    473         #Add the options specified by @options to the signature of the wrapped


/home/myorro/Sage/local/lib/python2.7/site-packages/sage/plot/graphics.pyc in show(self, filename, linkmode, **kwds)
   1816             filename = graphics_filename()
   1817
-> 1818         self.save(filename, **kwds)
   1819
   1820         if sage.plot.plot.EMBEDDED_MODE:


/home/myorro/Sage/local/lib/python2.7/site-packages/sage/misc/decorators.pyc in wrapper(*args, **kwds)
    469             kwds[self.name + "
options"] = suboptions
    470
--> 471             return func(*args, **kwds)
    472
    473         #Add the options specified by @options to the signature of the wrapped


/home/myorro/Sage/local/lib/python2.7/site-packages/sage/plot/graphics.pyc in save(self, filename, **kwds)
   2893             SageObject.save(self, filename)
   2894         else:
-> 2895             from matplotlib import rcParams
   2896             rc_backup = (rcParams['ps.useafm'], rcParams['pdf.use14corefonts'],
   2897                          rcParams['text.usetex']) # save the rcParams


/home/myorro/Sage/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/__init__.py in <module>()
    154 # cbook must import matplotlib only within function
    155 # definitions, so it is safe to import from it here.
--> 156 from matplotlib.cbook import is_string_like
    157 from matplotlib.compat import subprocess
    158


/home/myorro/Sage/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/cbook.py in <module>()
     26 from weakref import ref, WeakKeyDictionary
     27
---> 28 import numpy as np
     29 import numpy.ma as ma
     30


/home/myorro/Sage/local/lib/python2.7/site-packages/numpy/__init__.pyc in <module>()
    151         return loader(*packages, **options)
    152
--> 153     from . import add_newdocs
    154     __all__ = ['add_newdocs', 'ModuleDeprecationWarning']
    155


/home/myorro/Sage/local/lib/python2.7/site-packages/numpy/add_newdocs.py in <module>()
     11 from __future__ import division, absolute_import, print_function
     12
---> 13 from numpy.lib import add_newdoc
     14
     15 ###############################################################################


/home/myorro/Sage/local/lib/python2.7/site-packages/numpy/lib/__init__.py in <module>()
     16
     17 from . import scimath as emath
---> 18 from .polynomial import *
     19 #import convertcode
     20 from .utils import *


/home/myorro/Sage/local/lib/python2.7/site-packages/numpy/lib/polynomial.py in <module>()
     17 from numpy.lib.function_base import trim_zeros, sort_complex
     18 from numpy.lib.type_check import iscomplex, real, imag
---> 19 from numpy.linalg import eigvals, lstsq, inv
     20
     21 class RankWarning(UserWarning):


/home/myorro/Sage/local/lib/python2.7/site-packages/numpy/linalg/__init__.py in <module>()
     48 from .info import __doc__
     49
---> 50 from .linalg import *
     51
     52 from numpy.testing import Tester


/home/myorro/Sage/local/lib/python2.7/site-packages/numpy/linalg/linalg.py in <module>()
     27     )
     28 from numpy.lib import triu, asfarray
---> 29 from numpy.linalg import lapack_lite, _umath_linalg
     30 from numpy.matrixlib.defmatrix import matrix_power
     31 from numpy.compat import asbytes


ImportError: libgfortran.so.3: cannot open shared object file: No such file or directory


I didn't really understand what happened, so I ran the same plot code again, and this is what appeared

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-5-04a086d308e2> in <module>()
----> 1 plot(sinc, (x, -Integer(10), Integer(10)))


/home/myorro/Sage/local/lib/python2.7/site-packages/IPython/core/displayhook.pyc in __call__(self, result)
   
250             self.start_displayhook()
   
251             self.write_output_prompt()
--> 252             format_dict, md_dict = self.compute_format_data(result)
   
253             self.write_format_data(format_dict, md_dict)
   
254             self.update_user_ns(result)


/home/myorro/Sage/local/lib/python2.7/site-packages/IPython/core/displayhook.pyc in compute_format_data(self, result)
   
152
   
153         """
--> 154         return self.shell.display_formatter.format(result)
    155
    156     def write_format_data(self, format_dict, md_dict=None):


/home/myorro/Sage/local/lib/python2.7/site-packages/IPython/core/formatters.pyc in format(self, obj, include, exclude)
    198             md = None
    199             try:
--> 200                 data = formatter(obj)
    201             except:
    202                 # FIXME: log the exception


/home/myorro/Sage/local/lib/python2.7/site-packages/sage/misc/displayhook.pyc in __call__(self, obj)
    518             sage: fmt.set_display('simple')
    519         """

--> 520         if self.try_format_graphics(obj):
   
521             return ''
   
522         s = self.try_format_obj(obj)


/home/myorro/Sage/local/lib/python2.7/site-packages/sage/misc/displayhook.pyc in try_format_graphics(self, obj)
   
415         from sage.structure.sage_object import SageObject
   
416         if isinstance(obj, SageObject) and hasattr(obj, '_graphics_'):
--> 417             return obj._graphics_()
   
418         return False
   
419


/home/myorro/Sage/local/lib/python2.7/site-packages/sage/plot/graphics.pyc in _graphics_(self)
   
822              Graphics object consisting of 0 graphics primitives]
   
823         """
--> 824         self.show()
    825         return True
    826


/home/myorro/Sage/local/lib/python2.7/site-packages/sage/misc/decorators.pyc in wrapper(*args, **kwds)
    469             kwds[self.name + "
options"] = suboptions
    470
--> 471             return func(*args, **kwds)
    472
    473         #Add the options specified by @options to the signature of the wrapped


/home/myorro/Sage/local/lib/python2.7/site-packages/sage/plot/graphics.pyc in show(self, filename, linkmode, **kwds)
   1816             filename = graphics_filename()
   1817
-> 1818         self.save(filename, **kwds)
   1819
   1820         if sage.plot.plot.EMBEDDED_MODE:


/home/myorro/Sage/local/lib/python2.7/site-packages/sage/misc/decorators.pyc in wrapper(*args, **kwds)
    469             kwds[self.name + "
options"] = suboptions
    470
--> 471             return func(*args, **kwds)
    472
    473         #Add the options specified by @options to the signature of the wrapped


/home/myorro/Sage/local/lib/python2.7/site-packages/sage/plot/graphics.pyc in save(self, filename, **kwds)
   2893             SageObject.save(self, filename)
   2894         else:
-> 2895             from matplotlib import rcParams
   2896             rc_backup = (rcParams['ps.useafm'], rcParams['pdf.use14corefonts'],
   2897                          rcParams['text.usetex']) # save the rcParams


/home/myorro/Sage/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/__init__.py in <module>()
    154 # cbook must import matplotlib only within function
    155 # definitions, so it is safe to import from it here.
--> 156 from matplotlib.cbook import is_string_like
    157 from matplotlib.compat import subprocess
    158


/home/myorro/Sage/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/cbook.py in <module>()
     26 from weakref import ref, WeakKeyDictionary
     27
---> 28 import numpy as np
     29 import numpy.ma as ma
     30


/home/myorro/Sage/local/lib/python2.7/site-packages/numpy/__init__.py in <module>()
    151         return loader(*packages, **options)
    152
--> 153     from . import add_newdocs
    154     __all__ = ['add_newdocs', 'ModuleDeprecationWarning']
    155


/home/myorro/Sage/local/lib/python2.7/site-packages/numpy/add_newdocs.py in <module>()
     11 from __future__ import division, absolute_import, print_function
     12
---> 13 from numpy.lib import add_newdoc
     14
     15 ###############################################################################


/home/myorro/Sage/local/lib/python2.7/site-packages/numpy/lib/__init__.py in <module>()
     15 from .ufunclike import *
     16
---> 17 from . import scimath as emath
     18 from .polynomial import *
     19 #import convertcode


ImportError: cannot import name scimath


I'm sorry if I'm making you look at all the error reports. But I don't really know how to troubleshoot these kinds of errors yet. Can anyone please help me
(1) understand the problem
(2) fix the error

so that I may be able to try and fix something similar by myself in the future?

Daniel Krenn

unread,
Sep 9, 2014, 7:13:52 AM9/9/14
to sage-s...@googlegroups.com
Am 2014-09-09 um 05:03 schrieb Miguel Yorro:
> Hi! I'm using Craig Finch Sage Beginner's Guide to learn to use Sage.
> However, when I ran the following code (both in the notebook and
> terminal mode)
>
> |
> sage:var('x')
> x
> sage:sinc(x)=sin(x)/x
> sage:plot(sinc,(x,-10,10))

Try one of the following:

sage: var('x')
x
sage: sinc(x) = sin(x)/x

sage: sinc
x |--> sin(x)/x
sage: sinc(x)
sin(x)/x

sage: plot(sinc, (-10, 10))

sage: plot(sinc(x), (x, -10, 10))

Both work for me. "sinc" is a function, so if you use it directly as you
did, you don't have to specify a variable in plot. If you want to do
this, use "sinc(x)", which is a symbolic expression.

Daniel

Nils Bruin

unread,
Sep 9, 2014, 6:27:00 PM9/9/14
to sage-s...@googlegroups.com
On Monday, September 8, 2014 8:03:31 PM UTC-7, Miguel Yorro wrote:

     28 from numpy.lib import triu, asfarray
---> 29 from numpy.linalg import lapack_lite, _umath_linalg
     30 from numpy.matrixlib.defmatrix import matrix_power
     31 from numpy.compat import asbytes


ImportError: libgfortran.so.3: cannot open shared object file: No such file or directory


/home/myorro/Sage/local/lib/python2.7/site-packages/numpy/lib/__init__.py in <module>()
     15 from .ufunclike import *
     16
---> 17 from . import scimath as emath
     18 from .polynomial import *
     19 #import convertcode


ImportError: cannot import name scimath


I'm sorry if I'm making you look at all the error reports. But I don't really know how to troubleshoot these kinds of errors yet. Can anyone please help me
(1) understand the problem
(2) fix the error

Both errors seem to indicate that your sage failed to properly "import" (python speak for "initialize") some component of "numpy". It's a little strange that executing the same code twice yields different errors. I assume this was in the same session? In that case I can imagine that the first (failed) import of numpy.linalg did partially succeed, changing the state such that the second time, a different failure arose.

You may want to try the command

sage: from numpy.linalg import lapack_lite, _umath_linalg

in a fresh sage session to confirm that initializing this component (which should normally work) indeed fails for you. Similarly,

sage: import numpy.lib.scimath

should normally work. If it doesn't then your sage installation is likely broken.
Reply all
Reply to author
Forward
0 new messages