7

I have installed pip install ipython-sql. I am trying to run

%load_ext sql

but it returns

The sql module is not an IPython extension.

How can I get sql running in ipython?

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
Echo
  • 667
  • 3
  • 8
  • 19

4 Answers4

3

Is it possible that you are running a different version of python than you've installed the extension for? After you execute the ipython command, if the first line of output is something like:

Python 3.5.0 (default, Sep 14 2015, 02:37:27)

which indicates Python 3, rather than something like:

Python 2.7.11 (default, Feb 23 2016, 16:17:28)

which indicates Python 2, then you should try installing the extension using pip3

pip3 install ipython-sql

in order to make it available to the version of ipython that you are running.

Matthew Cox
  • 1,047
  • 10
  • 23
  • Hi I am using Python 2. I am using Jupiter QtConsole, on the top it says: Jupyter QtConsole 4.1.1 Python 2.7.11 |Anaconda 2.1.0 (x86_64)| (default, Dec 6 2015, 18:57:58) – Echo Mar 21 '16 at 22:32
1

Since we're talking about ipython, I'd assume you've used pip install with Jupyter Lab. Sometimes the lab is running on kernels different than our work environment. It seems there is some dependency issue with your project (either with the environment itself or with the version you're running). If you're working with conda, I'd scrape the environment and start from scratch, same for python venv.

I also recommend opening a ticket, since it's an open-source project, the maintaining team would likely respond and help you debug it faster.

Lastly, I recommend trying it with JupySQL which is a fork of ipython-sql with a lot of bug fixes and new features.

I just tried the following via a vanilla Jupyter notebook and it passed (running on an empty conda env):

!pip install jupysql --quiet
%load_ext sql
%sql engine
%%sql
SELECT * FROM numbers
Ido Michael
  • 109
  • 7
0

Since you're using Anaconda's version of Python, make sure you install with conda, which is the relevant package manager. You'll need to install with the following command:

conda install -c conda-forge ipython-sql=0.3.6

Source: https://anaconda.org/conda-forge/ipython-sql

haudarren
  • 425
  • 1
  • 4
  • 12
0

I reinstalled ipython-sql using the following command, and everything worked out.You are not saying you are running conda thus I am assuming you are simply using a python in jupyter-notebook. This worked for python versions 3.6.9

sudo -H python3 -m pip install ipython-sql

Seems as if this happened to me because I did not have access to pip's parent directory. (in my case I was in a virtual environment) attempting to make the normal pip install ipython-sql which is why I used the -H flag after sudo.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Scooby
  • 1
  • 1