'IPython Notebook and SQL: 'ImportError: No module named sql' when running '%load_ext sql'
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!
Solution 1:[1]
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.
Solution 2:[2]
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
Solution 3:[3]
I know this answer will be (very) late to contribute to the discussion but maybe it will help someone. I found out what worked for me by following Thomas, who commented above. However, with a bit of a caveat, that I was using pyenv to setup and manage python on my local machine.
So when running sys.executable in a jupyter notebook cell I found out my python path was /usr/local/Cellar/jupyterlab/3.2.8/libexec/bin/python3.9, while I expected it to be somewhere along the lines of '/Users/<USER_NAME>/.pyenv/versions/3.9.2/bin/python'.
This error was attributed to me having installed jupyter through command brew install jupyter instead of pyenv exec pip install jupyter. I proceeded to uninstall jupyter with brew and then executing the second command, which now got jupyter up and running!
(note that you would first have to have pyenv setup properly).
Solution 4:[4]
I doubt you're using different IPython Notebook kernel other than which you've installed ipython-sql in.
IPython Notebook can have more than one kernel. If it is the case, make sure you're in the right place first.
Solution 5:[5]
Ok i finally found the answer now. It´s working with :
val uri = data!!.getParcelableExtra<Uri>(RingtoneManager.EXTRA_RINGTONE_PICKED_URI)
then i can set the new ringtone with
ringtone = RingtoneManager.getRingtone(this, uri)
and start playing it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ashkan |
| Solution 2 | KHAN |
| Solution 3 | Fredrik HD |
| Solution 4 | David Jung |
| Solution 5 | Da_Pusti |
