catherinedevlin / ipython-sql

%%sql magic for IPython, hopefully evolving into full SQL client
MIT License
1.79k stars 369 forks source link

Installing ipython-sql prevents ipython notebook from starting #29

Open stevenbeeckman opened 9 years ago

stevenbeeckman commented 9 years ago

Hi,

I'm very new to Python, IPython and its Notebook concept, yet also interested in ipython-sql. I'm trying to get it all running inside of Ubuntu/Vagrant on my Mac. I followed [these instructions]() to get ipython notebook running. (I guess it's an old Ubuntu 12, just followed Vagrant's instructions.)

After I got ipython notebook running (I even got 3 notebooks saved :)), I tried to install your %sql magic by doing sudo pip install ipython-magic but things probably went not as intented when sqlalchemy was installed:

... during lib/sqlalchemy/cextension/processors.c:10:20: fatal error: Python.h: No such file or directory ...

WARNING: The C extension could not be compiled, speedups are not enabled. Plain-Python build succeeded.

... Successfully installed ipython-sql prettytable ipython sqlalchemy sqlparse six Cleaning up...

I don't really care yet about speedups so was happy with the Plain-Python build. I tried to run ipython notebook --ip=0.0.0.0 again, but got this:

vagrant@precise32:~$ ipython notebook --ip=0.0.0.0
/usr/local/lib/python2.7/dist-packages/IPython/frontend.py:30: UserWarning: The top-level `frontend` package has been deprecated. All its subpackages have been moved to the top `IPython` level.
  warn("The top-level `frontend` package has been deprecated. "
Traceback (most recent call last):
  File "/usr/bin/ipython", line 8, in <module>
    launch_new_instance()
  File "/usr/local/lib/python2.7/dist-packages/IPython/config/application.py", line 573, in launch_instance
    app.initialize(argv)
  File "<string>", line 2, in initialize
  File "/usr/local/lib/python2.7/dist-packages/IPython/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 321, in initialize
    super(TerminalIPythonApp, self).initialize(argv)
  File "<string>", line 2, in initialize
  File "/usr/local/lib/python2.7/dist-packages/IPython/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/IPython/core/application.py", line 369, in initialize
    self.parse_command_line(argv)
  File "/usr/local/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 316, in parse_command_line
    return super(TerminalIPythonApp, self).parse_command_line(argv)
  File "<string>", line 2, in parse_command_line
  File "/usr/local/lib/python2.7/dist-packages/IPython/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/IPython/config/application.py", line 471, in parse_command_line
    return self.initialize_subcommand(subc, subargv)
  File "<string>", line 2, in initialize_subcommand
  File "/usr/local/lib/python2.7/dist-packages/IPython/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/IPython/config/application.py", line 402, in initialize_subcommand
    subapp = import_item(subapp)
  File "/usr/local/lib/python2.7/dist-packages/IPython/utils/importstring.py", line 42, in import_item
    module = __import__(package, fromlist=[obj])
  File "/usr/local/lib/python2.7/dist-packages/IPython/html/notebookapp.py", line 31, in <module>
    from jinja2 import Environment, FileSystemLoader
ImportError: No module named jinja2
vagrant@precise32:~$ 

OK, next step: installing jinja2.

vagrant@precise32:~$ sudo pip install jinja2
Downloading/unpacking jinja2
  Downloading Jinja2-2.7.3.tar.gz (378Kb): 378Kb downloaded
  Running setup.py egg_info for package jinja2

    warning: no files found matching '*' under directory 'custom_fixers'
    warning: no previously-included files matching '*' found under directory 'docs/_build'
    warning: no previously-included files matching '*.pyc' found under directory 'jinja2'
    warning: no previously-included files matching '*.pyc' found under directory 'docs'
    warning: no previously-included files matching '*.pyo' found under directory 'jinja2'
    warning: no previously-included files matching '*.pyo' found under directory 'docs'
Downloading/unpacking markupsafe (from jinja2)
  Downloading MarkupSafe-0.23.tar.gz
  Running setup.py egg_info for package markupsafe

Installing collected packages: jinja2, markupsafe
  Running setup.py install for jinja2

    warning: no files found matching '*' under directory 'custom_fixers'
    warning: no previously-included files matching '*' found under directory 'docs/_build'
    warning: no previously-included files matching '*.pyc' found under directory 'jinja2'
    warning: no previously-included files matching '*.pyc' found under directory 'docs'
    warning: no previously-included files matching '*.pyo' found under directory 'jinja2'
    warning: no previously-included files matching '*.pyo' found under directory 'docs'
  Running setup.py install for markupsafe

    building 'markupsafe._speedups' extension
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c markupsafe/_speedups.c -o build/temp.linux-i686-2.7/markupsafe/_speedups.o
    markupsafe/_speedups.c:12:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    ==========================================================================
    WARNING: The C extension could not be compiled, speedups are not enabled.
    Failure information, if any, is above.
    Retrying the build without the C extension now.

    ==========================================================================
    WARNING: The C extension could not be compiled, speedups are not enabled.
    Plain-Python installation succeeded.
    ==========================================================================
Successfully installed jinja2 markupsafe
Cleaning up...
vagrant@precise32:~$

I really should get those Python headers installed. But again, I don't really care right now about blazing fast performance. I just want to get it working. Anyway, let's see if I get the notebook server running:

agrant@precise32:~$ ipython notebook --ip=0.0.0.0
/usr/local/lib/python2.7/dist-packages/IPython/frontend.py:30: UserWarning: The top-level `frontend` package has been deprecated. All its subpackages have been moved to the top `IPython` level.
  warn("The top-level `frontend` package has been deprecated. "
Traceback (most recent call last):
  File "/usr/bin/ipython", line 8, in <module>
    launch_new_instance()
  File "/usr/local/lib/python2.7/dist-packages/IPython/config/application.py", line 573, in launch_instance
    app.initialize(argv)
  File "<string>", line 2, in initialize
  File "/usr/local/lib/python2.7/dist-packages/IPython/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 321, in initialize
    super(TerminalIPythonApp, self).initialize(argv)
  File "<string>", line 2, in initialize
  File "/usr/local/lib/python2.7/dist-packages/IPython/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/IPython/core/application.py", line 369, in initialize
    self.parse_command_line(argv)
  File "/usr/local/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 316, in parse_command_line
    return super(TerminalIPythonApp, self).parse_command_line(argv)
  File "<string>", line 2, in parse_command_line
  File "/usr/local/lib/python2.7/dist-packages/IPython/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/IPython/config/application.py", line 471, in parse_command_line
    return self.initialize_subcommand(subc, subargv)
  File "<string>", line 2, in initialize_subcommand
  File "/usr/local/lib/python2.7/dist-packages/IPython/config/application.py", line 75, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/IPython/config/application.py", line 402, in initialize_subcommand
    subapp = import_item(subapp)
  File "/usr/local/lib/python2.7/dist-packages/IPython/utils/importstring.py", line 42, in import_item
    module = __import__(package, fromlist=[obj])
  File "/usr/local/lib/python2.7/dist-packages/IPython/html/notebookapp.py", line 49, in <module>
    raise ImportError(msg + ", but you have %s" % tornado.version)
ImportError: The IPython Notebook requires tornado >= 4.0, but you have 2.1
vagrant@precise32:~$

Next up: sudo apt-get install --upgrade tornado. Again some whining about no header files, so I finally did sudo apt-get install build-essential python-dev and ran the tornado upgrade again.

Next thing missing: jsonschema. Installed that through pip. Ran ipython notebook --ip=0.0.0.0 again. got this:

agrant@precise32:~$ ipython notebook --ip=0.0.0.0
/usr/local/lib/python2.7/dist-packages/IPython/frontend.py:30: UserWarning: The top-level `frontend` package has been deprecated. All its subpackages have been moved to the top `IPython` level.
  warn("The top-level `frontend` package has been deprecated. "
[I 23:27:59.202 NotebookApp] Using existing profile dir: u'/home/vagrant/.ipython/profile_default'
[I 23:27:59.256 NotebookApp] Writing notebook server cookie secret to /home/vagrant/.ipython/profile_default/security/notebook_cookie_secret
[I 23:27:59.261 NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
[W 23:27:59.288 NotebookApp] Terminals not available (error was No module named terminado)
[I 23:27:59.291 NotebookApp] Serving notebooks from local directory: /home/vagrant
[I 23:27:59.291 NotebookApp] 0 active kernels
[I 23:27:59.291 NotebookApp] The IPython Notebook is running at: http://0.0.0.0:8888/
[I 23:27:59.292 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 23:27:59.292 NotebookApp] No web browser found: could not locate runnable browser.
Traceback (most recent call last):
  File "/usr/bin/ipython", line 8, in <module>
    launch_new_instance()
  File "/usr/local/lib/python2.7/dist-packages/IPython/config/application.py", line 574, in launch_instance
    app.start()
  File "/usr/local/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 367, in start
    return self.subapp.start()
  File "/usr/local/lib/python2.7/dist-packages/IPython/html/notebookapp.py", line 1064, in start
    self.io_loop = ioloop.IOLoop.current()
AttributeError: type object 'IOLoop' has no attribute 'current'

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@scipy.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    c.Application.verbose_crash=True

vagrant@precise32:~$

I tried to install terminado but that didn't solve the lack of having a browser connected. Which seems to me to be a chicken and egg problem.

I will also cross-post this issue to the IPython repo as I figure it's more an IPython problem than an ipython-sql thing. It broke however while trying to get ipython-sql running. ;-)

Sorry for the long bug report.

stevenbeeckman commented 9 years ago

Reproduction gist: https://gist.github.com/stevenbeeckman/beffbbd867b93575ac48

stevenbeeckman commented 9 years ago

Inspecting further: the sudo pip install ipython-sql step uninstalls ipython (from apt-get) and installs another ipython version, which probably breaks a few things.

stevenbeeckman commented 9 years ago

Same happens when installing ipython-sql via the git master download.