3

I am getting this error when executing any source ipython block such as this one:

#+BEGIN_SRC ipython :session :results output drawer

# Compute areas and colors
import numpy as np
import matplotlib.pyplot as plt

N = 150
r = 2 * np.random.rand(N)
theta = 2 * np.pi * np.random.rand(N)
area = 200 * r**2
colors = theta

ax = plt.subplot(111, projection='polar')
c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)

#+END_SRC

There was a fatal error trying to process the request. See ob-ipython-debug

ob-ipython-debug:

 File "/Users/USER/.emacs.d/elpa/ob-ipython-20180113.929/client.py", line 1, in <module>
    import jupyter_client as client
ImportError: No module named jupyter_client

I don't know what can be wrong (I have all the necessary dependencies requires like ipython, jupyter, python, and obviously ob-ipython). Any help appreciated.

Thanks, EG

Trey
  • 865
  • 5
  • 20
  • BTW, the ob-ipython-debug says: Traceback (most recent call last): File "/Users/USER/.emacs.d/elpa/ob-ipython-20180113.929/client.py", line 1, in import jupyter_client as client ImportError: No module named jupyter_client" – Emmanuel Goldstein Jan 31 '18 at 15:31
  • Can you post the part of the `.emacs` related with your babel configuration? – Dox Jan 31 '18 at 16:05
  • Sure, but I don't think it's related to babel (org-babel-do-load-languages 'org-babel-load-languages '((matlab . t) (python . t) (ipython . t) ;(emacs-lisp . t) ;(shell . t) ;(matlab . t) ;(dot . t) ;(R . t) )) – Emmanuel Goldstein Jan 31 '18 at 16:09
  • [Sorry, I don't seem to know how to format code in stackexchange] – Emmanuel Goldstein Jan 31 '18 at 16:10
  • I'm getting the same error. I've checked and the file IS there. I tried to give execution permission to the file... but I'm still getting the error. I also have the line `(require 'ob-ipython)` in the `.emacs` file. – Dox Jan 31 '18 at 16:37
  • Thanks, it's very annoying! I also have the require line in my init file. Let's see if someone can help. – Emmanuel Goldstein Jan 31 '18 at 16:52
  • Maybe we need to specify the path to the client? How to do this? – Emmanuel Goldstein Jan 31 '18 at 16:53
  • @EmmanuelGoldstein: re. formatting code - just indent everything by four spaces and paste it in. You should edit the question and do that with your original code as well: images of code are frowned upon. – NickD Jan 31 '18 at 17:51
  • @Nick, I can't seem to be able to edit my comments. – Emmanuel Goldstein Jan 31 '18 at 17:57
  • To edit comments, I believe you need to do it quickly (within 5 minutes) and you have to have enough reputation (but I don't know how much is enough). But you should be able to edit your question. – NickD Jan 31 '18 at 17:59
  • Understood, thanks! I have included the comment in my question for completion. – Emmanuel Goldstein Jan 31 '18 at 18:00
  • But you deleted the image of the code without adding the text of the code. But in any case, it's clear you are missing the `jupyter_client` module. – NickD Jan 31 '18 at 18:02
  • Yes, the code was just an example. I just added a short sample code. – Emmanuel Goldstein Jan 31 '18 at 18:29

1 Answers1

1

On my system, this error happens because my jupyter installation is based on python3, while python-shell-interpreter in emacs is python. This can be fixed by running M-S-: (setq python-shell-interpreter "python3"). You can put this command in your init file if you only use python3.

For those on Debian/Ubuntu, this can also be fixed by installing python2.7 version of jupyter by running apt install python-jupyter-client python-jupyter-console. Note that Debian packages jupyter-* are all python3 based.

Another way to deal with this issue is by using python environments. If you're using Anaconda and installed jupyter through it, running conda activate before you start emacs should point your shell's python to conda's version.