Just set up an IPython Notebook on Ubuntu 16.04 but I can't use %load_ext sql
.
I get: ImportError: No module named sql
I've tried using pip and pip3 with and without sudo
to install ipython-sql. All 4 times it installed without issue but nothing changes on the notebook.
Thanks in advance!
If you're trying to connect the IBM database and came across this problem and the above solutions couldn't do it for you, you could give this a chance. (By the way, this error usually means one of your package installations doesn't meet the requirements or more probably: you're in the wrong kernel/virtual environment and the Jupyter instance can't run your command from the specified packages.)
From JupyterLab or Jupyter Notebook go to Kernel>Change Kernel
and change the kernel that you've installed the packages. Wait for it to establish a connection. Then use 0, 0
to restart kernel (or Kernel>Restart Kernel
Go to any cell and run the below commands to install packages in the current kernel.
!pip install sqlalchemy==1.3.9
!pip install ibm_db_sa
!pip install ipython-sql
Now try
%load_ext sql
I know it's been a long time, but I faced the same issue, and Thomas' advice solved my problem. Just outlining what I did here.
When I ran sys.executable
in the notebook I saw /usr/bin/python2
, while the pip I used to install the package was /usr/local/bin/pip
(to find out what pip
you are using, just do which pip
or sudo which pip
if you are installing packages system-wide). So I reinstalled ipython-sql
using the following command, and everything worked out just fine.
sudo -H /usr/bin/python2 -m pip install ipython-sql
This is odd since I always install my packages using pip
. I'm wondering maybe there's something special about the magic functions in Jupyter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With