catherinedevlin / ipython-sql

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

TypeError: Error when calling the metaclass bases on %load_ext sql #87

Open davidthewatson opened 7 years ago

davidthewatson commented 7 years ago

I installed this module using pip, but I couldn't get the

%load_ext sql

line to work.

I then uninstalled the module, checked that it was gone, and tried to load it directly in ipython, but it fails at import time in exactly the same way that it fails in my ipython notebook. I'm not sure what's wrong but hopefully this output will provide a clue:

(shingledecker) ✔ ~/Source/shingledecker [120-ipython-notebook|✚ 2…3⚑ 3] 
13:57 $ pip uninstall ipython-sql
Uninstalling ipython-sql-0.3.8:
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/ipython_sql-0.3.8.dist-info/DESCRIPTION.rst
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/ipython_sql-0.3.8.dist-info/INSTALLER
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/ipython_sql-0.3.8.dist-info/METADATA
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/ipython_sql-0.3.8.dist-info/RECORD
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/ipython_sql-0.3.8.dist-info/WHEEL
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/ipython_sql-0.3.8.dist-info/metadata.json
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/ipython_sql-0.3.8.dist-info/top_level.txt
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/sql/__init__.py
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/sql/__init__.pyc
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/sql/column_guesser.py
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/sql/column_guesser.pyc
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/sql/connection.py
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/sql/connection.pyc
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/sql/magic.py
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/sql/magic.pyc
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/sql/parse.py
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/sql/parse.pyc
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/sql/run.py
  /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/sql/run.pyc
Proceed (y/n)? y
  Successfully uninstalled ipython-sql-0.3.8
(shingledecker) ✔ ~/Source/shingledecker [120-ipython-notebook|✚ 2…3⚑ 3] 
13:58 $ ipython
Python 2.7.12 (default, Sep  5 2016, 20:55:16) 
Type "copyright", "credits" or "license" for more information.

IPython 2.4.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import sql
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-0f1b1693ec93> in <module>()
----> 1 import sql

ImportError: No module named sql

In [2]: 
Do you really want to exit ([y]/n)? y
(shingledecker) ✔ ~/Source/shingledecker [120-ipython-notebook|✚ 2…3⚑ 3] 
13:59 $ pip install ipython-sql
Collecting ipython-sql
Requirement already satisfied: sqlalchemy>=0.6.7 in /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages (from ipython-sql)
Requirement already satisfied: ipython-genutils>=0.1.0 in /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages (from ipython-sql)
Requirement already satisfied: sqlparse in /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages (from ipython-sql)
Requirement already satisfied: ipython>=1.0 in /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages (from ipython-sql)
Requirement already satisfied: prettytable in /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages (from ipython-sql)
Requirement already satisfied: six in /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages (from ipython-sql)
Requirement already satisfied: gnureadline; sys_platform == "darwin" and platform_python_implementation == "CPython" in /Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages (from ipython>=1.0->ipython-sql)
Installing collected packages: ipython-sql
Successfully installed ipython-sql-0.3.8
(shingledecker) ✔ ~/Source/shingledecker [120-ipython-notebook|✚ 2…3⚑ 3] 
13:59 $ ipython
Python 2.7.12 (default, Sep  5 2016, 20:55:16) 
Type "copyright", "credits" or "license" for more information.

IPython 2.4.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import sql
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-0f1b1693ec93> in <module>()
----> 1 import sql

/Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/sql/__init__.pyc in <module>()
----> 1 from .magic import *

/Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/sql/magic.py in <module>()
     21 
     22 @magics_class
---> 23 class SqlMagic(Magics, Configurable):
     24     """Runs SQL statement on a database, specified by SQLAlchemy connect string.
     25 

/Users/davidwatson/.virtualenvs/shingledecker/lib/python2.7/site-packages/IPython/utils/traitlets.pyc in __new__(mcls, name, bases, classdict)
    434                     vinst.name = k
    435                     classdict[k] = vinst
--> 436         return super(MetaHasTraits, mcls).__new__(mcls, name, bases, classdict)
    437 
    438     def __init__(cls, name, bases, classdict):

TypeError: Error when calling the metaclass bases
    metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

In [2]: 
Do you really want to exit ([y]/n)? y
(shingledecker) ✔ ~/Source/shingledecker [120-ipython-notebook|✚ 2…3⚑ 3] 
13:59 $ python --version
Python 2.7.12
(shingledecker) ✔ ~/Source/shingledecker [120-ipython-notebook|✚ 2…3⚑ 3] 
14:00 $ ipython --version
2.4.1
timtan commented 2 years ago

it is usually you don't correctly install the plugin.

e.g.

the Jupiter notebook is install in global and your pip is in your local development env.

maybe try to figure out by which