bug-report jupiter's ipython notebook #10646

Open
ethan1987-2 opened this Issue Jun 8, 2017 · 3 comments

Comments

Projects
None yet
2 participants

i was scripting with spyder 3 and using ipython and noticed that jupiter's nb can't work this:
import scipy as sp
...
sp.integrate.nquad(f,intervs)

it yields and error stating that there is no integrate function in module sp

but if you do:
import integrate from scipy
...
integrate.nquad(f,intervs)

then there is no problem at all!

Owner

Carreau commented Jun 8, 2017

but then how come there's no problem doing:
import scipy as sp
...
sp.integrate.nquad(f,intervs)
in spyder 3 but it is a problem in jupyter...it's like you're coding on the same language but not at the same time. I do run code like that in spyder with no problems at all and then it doesn't work on jupyter. it doesn't make sense

Owner

Carreau commented Jun 9, 2017

Well because something else does import it.
I don't know what, I don't have the code to inspect, but it's easy to replicate:

$ cat foo.py
import scipy.integrate

$ python
Python 3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 13:19:00)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy as sp
>>> sp.integrate
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'scipy' has no attribute 'integrate'
>>> import foo
>>> sp.integrate
<module 'scipy.integrate' from '/Users/bussonniermatthias/anaconda/lib/python3.6/site-packages/scipy/integrate/__init__.py'>
>>>

So if something else is importing it, it will be available, and as you see it's Python behavior not IPython or Jupyter. Spyder may do imports as well, maybe it import scipy.integrate. @ccordoba12 an idea ofwhere this difference could come from on the Spyder Side ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment