Hello,

I'm trying to use sympy in a Jupyter notebook, however, it seems that
sympy.init_session() does too much magic.  If I call it without
arguments it fails with this exception:

> ---------------------------------------------------------------------------
> MultipleInstanceError                     Traceback (most recent call last)
> <ipython-input-15-93c617afb26a> in <module>()
> ----> 1 sympy.init_session()
> 
> /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/interactive/session.py
>  in init_session(ipython, pretty_print, order, use_unicode, use_latex, quiet, 
> auto_symbols, auto_int_to_Integer, str_printer, pretty_printer, 
> latex_printer, argv)
>     431     else:
>     432         ip = init_ipython_session(argv=argv, 
> auto_symbols=auto_symbols,
> --> 433             auto_int_to_Integer=auto_int_to_Integer)
>     434 
>     435         if V(IPython.__version__) >= '0.11':
> 
> /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sympy/interactive/session.py
>  in init_ipython_session(argv, auto_symbols, auto_int_to_Integer)
>     262         # don't draw IPython banner during initialization:
>     263         app.display_banner = False
> --> 264         app.initialize(argv)
>     265 
>     266         if auto_symbols:
> 
> <decorator-gen-112> in initialize(self, argv)
> 
> /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/traitlets/config/application.py
>  in catch_config_error(method, app, *args, **kwargs)
>      85     """
>      86     try:
> ---> 87         return method(app, *args, **kwargs)
>      88     except (TraitError, ArgumentError) as e:
>      89         app.print_help()
> 
> /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/terminal/ipapp.py
>  in initialize(self, argv)
>     315         self.init_path()
>     316         # create the shell
> --> 317         self.init_shell()
>     318         # and draw the banner
>     319         self.init_banner()
> 
> /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/terminal/ipapp.py
>  in init_shell(self)
>     331         self.shell = 
> self.interactive_shell_class.instance(parent=self,
>     332                         profile_dir=self.profile_dir,
> --> 333                         ipython_dir=self.ipython_dir, 
> user_ns=self.user_ns)
>     334         self.shell.configurables.append(self)
>     335 
> 
> /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/traitlets/config/configurable.py
>  in instance(cls, *args, **kwargs)
>     421             raise MultipleInstanceError(
>     422                 'Multiple incompatible subclass instances of '
> --> 423                 '%s are being created.' % cls.__name__
>     424             )
>     425 
> 
> MultipleInstanceError: Multiple incompatible subclass instances of 
> TerminalInteractiveShell are being created.
> 

IPython is version 6.2.0, Sympy is version 1.1.1.

I tried playing with the ipython argument to init_session() but both
True and False values did not do much good (did not get something
usable).  The strange thing is that I have a sympy working just fine in
a Jupyter notebook on a work machine where I use Anaconda (this machine
uses an macports instead).  I don't know if Anaconda patches Sympy
somehow or if it uses an older version that does not have this problem.
I can check that tomorrow.

Looking at the code for init_session() it seems that the possibility of
it being called in an IPython session is not handled.

This bug report is about the same issue:

https://github.com/sympy/sympy/issues/13319

Thanks. Cheers,
Daniele

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/94e5c054-c039-9ebb-fca9-23e53efc1cc5%40grinta.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to