I am trying to import pandas
in an ipython (2.2.0, running python 3.3.5) notebook in my browser, which fails with
[...]
/usr/local/lib/python3.3/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 ###############################################################################
/usr/local/lib/python3.3/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
However, in both pure python and non-notebook ipython, import pandas
and the problematic line of from numpy.lib import add_newdoc
run without a problem, and the file /usr/local/lib/python3.3/site/site-packages/numpy/lib/scimath.py
exists and has the same permissions and creation date as the __init__.py
in the same directory.
How do I debug this error? What does ipython notebook
change about imports as compared to cli ipython
?
See this previous question and answer - https://stackoverflow.com/a/15622021/1766755.
A key difference between the IPy notebook and CLI is the default behavior of the
os.path
var, as well as the notebook settingnotebook_dir
.Obviously in the IPy notebook, pandas is not finding the scimath module. If you look closely at the traceback, you'll see the line
This is a relative path import, the . signifying a request to import a module from the same directory. Depending on where the CLI is begun vs where you tell IPython to think it's running from, this could be the cause of numpy not finding scimath. I could be wrong, but it's happened to me before.