gregsexton / ob-ipython

org-babel integration with Jupyter for evaluation of (Python by default) code blocks
739 stars 109 forks source link

failed to start ob-ipython #141

Open yitang opened 6 years ago

yitang commented 6 years ago

Hi, ob-ipython works fine for me on windows, but i just tried it on my ubuntu machine, and i got this error: please could you have a look?

Yi

--------------------------------------------------------------------------- OSError Traceback (most recent call last) ~/git/.emacs.d/.cask/25.3/elpa/ob-ipython-20171111.740/client.py in ()  58 args = parser.parse_args()  59  ---> 60 c = create_client(args.conn_file)  61   62 with interested_lock:

~/git/.emacs.d/.cask/25.3/elpa/ob-ipython-20171111.740/client.py in create_client(name)  41 cf = find_connection_file(name)  42 else: ---> 43 cf = find_connection_file('emacs-' + name)  44 c = client.BlockingKernelClient(connection_file=cf)  45 c.load_connection_file()

~/.local/lib/python3.5/site-packages/jupyter_client/connect.py in find_connection_file(filename, path, profile)  210 matches = [ os.path.abspath(m) for m in matches ]  211 if not matches: --> 212 raise IOError("Could not find %r in %r" % (filename, path))  213 elif len(matches) == 1:  214 return matches[0]

OSError: Could not find 'emacs-none' in ['.', '/run/user/1000/jupyter']

jchkoch commented 6 years ago

Hi, I seem to be getting the same error with ob-ipython using my opensuse leap 42.2 machine:

Traceback (most recent call last): File "/home/jkoch/.emacs.d/elpa/ob-ipython-20171111.740/client.py", line 60, in c = create_client(args.conn_file) File "/home/jkoch/.emacs.d/elpa/ob-ipython-20171111.740/client.py", line 43, in create_client cf = find_connection_file('emacs-' + name) File "/home/jkoch/anaconda3/lib/python3.6/site-packages/jupyter_client/connect.py", line 189, in find_connection_file raise IOError("Could not find %r in %r" % (filename, path)) OSError: Could not find 'emacs-new' in ['.', '/run/user/1000/jupyter']

Thought this might explain the above error in a little more detail. Any feedback on this would be appreciated as it suddenly stopped working from one day to the next and I am a bit perplexed as I haven't changed anything in my config.

Thanks, James

hooger commented 6 years ago

Hello,

same here, ob-ipython worked nicely, and now it does not. Yesterday I upgraded my ob-ipython package from Emacs package manager, my hunch is that it may have caused the issue. As I trace it back it seems, that create_client calls find_connection_file from jupyter/connect.py with empty path argument, so it falls back to jupyter_runtime_dir. For me it is /run/user/1000/jupyter which does not exists.

As a workaround running jupyter-console creates the folder and a connection file, which can be used to connect to (setting the created json file as :session kernel-xxxxx.json), but some fix would be nice.

Thanks in advance, hooger

jchkoch commented 6 years ago

Thanks @hooger for the workaround. It seems to work for me as well. I'll try to find some time to look more into this.

vapniks commented 6 years ago

That workaround didn't work for me. Instead I deleted all occurrences of "--simple-prompt" from ob-ipython.el since this is no longer a valid flag for recent versions of jupyter.

yitang commented 6 years ago

@vapniks which jupyter version are you using?

vapniks commented 6 years ago

@yitang 4.2.1

falematte commented 6 years ago

Same problem here. Anyone looking into this?

kailukowiak commented 6 years ago

I have a similar problem. I first got a long string of text like the first post. After I added (setq python-shell-interpreter "/Applications/anaconda/bin/python") in my init.el i started getting erros that were more legible. Currently:

Traceback (most recent call last):
  File "/Users/kailukowiak/.emacs.d/elpa/ob-ipython-20180224.153/client.py", line 60, in <module>
    c = create_client(args.conn_file)
  File "/Users/kailukowiak/.emacs.d/elpa/ob-ipython-20180224.153/client.py", line 43, in create_client
    cf = find_connection_file('emacs-' + name)
  File "/Applications/anaconda/lib/python3.6/site-packages/jupyter_client/connect.py", line 212, in find_connection_file
    raise IOError("Could not find %r in %r" % (filename, path))
OSError: Could not find 'emacs-mysession' in ['.', '/Users/kailukowiak/Library/Jupyter/runtime']

is my error.

I've tried exploring the python code in client.py file but I'm unsure if I should direct the file to creat a emacs-mysession file in the anaconda path or something else. Does anybody have any ideas?

kailukowiak commented 6 years ago

https://github.com/ipython/ipykernel/issues/151#issuecomment-267816538 I then re installed ipython and jupyter_console/client. This fixed my issue but I need to now figure how to get the code to show underneath the code chunk instead of in a seperate pannel.

jchkoch commented 6 years ago

@kaiserxc I see you are using the Anaconda python distribution. When you re-installed ipython and jupyter_console/client, what versions do you now have?

kailukowiak commented 6 years ago

@jchkoch

$ ipython --version
6.4.0
$ jupyter-console --version
5.2.0
$ jupyter --version
4.4.0

jupyter-client doesn't show up from bash but I got this from ipython:

In [2]: jupyter_client.__version__
Out[2]: '5.2.3'

I am not sure how to check which version I was using before. However, the reinstall seems to have fixed everything.

Unfortunetly I also ran this fix, which is right below the original comment that I linked too. https://github.com/ipython/ipykernel/issues/151#issuecomment-304085269

So I cant be sure which one fixed it. My approach was not very scientific.

What I can say is that I:

  1. Set the interpreter to a specific version (setq python-shell-interpreter "/Applications/anaconda/bin/python"). I imagine that you could change this to your own python environment if you don't have conda.
  2. Deleted ipython, jupyter-console and jupyter-client and reinstalled.
  3. Updated conda update ipykernel.

Also, since you already have a pretty error message: https://github.com/gregsexton/ob-ipython/issues/141#issuecomment-345925372, compared to @yitang https://github.com/gregsexton/ob-ipython/issues/141#issue-275011207 I think you don't need to do step 1.

Edit: I am pretty sure I updated jupyter-console/client before, so I think maybe some paths had gotten messed up and the reinstall fixed this but I am not 100% sure.

jchkoch commented 6 years ago

@kaiserxc Thanks for the quick reply. I tried your approach to fix the error; however, in the end I managed to get it working again with a fresh install of anaconda and ob-ipython (I think my paths were messed up... too much hacking...).

kailukowiak commented 6 years ago

@jchkoch there is nothing quite as efficient as a restart/re-install. For people looking at this thread in the future, I would suggest trying my approach first just because it takes less time, but I think ob-ipython works under the correct install and anyone having issues like this should not give up.

jchkoch commented 6 years ago

@kaiserxc not sure whether you figured out how to display results underneath the code block instead of a separate panel (as you mentioned in your previous comment but referring to this issue (#10) the best way to do this, is with the :results output property on code blocks. Hope this helps.

kailukowiak commented 6 years ago

@jchkoch I saw that and I got it working. My issue is that I have to choose, in advance, how to set up the SRC chunk. i.e. I would need to include either :results output or :results raw drawer which is annoyingly inefficient compared to a jupyter notebook or even the iPython REPL.

Also, it is difficult to print and show a graph. For example, lets say I create a function that displays a graph and text based on a condition. This would not display in the output easily.

Do you have any solutions?

jchkoch commented 6 years ago

@kaiserxc For including :results in the set up of each SRC chunk, I would set up some sort of snippet as shown in the README for ob-ipython. That would be more efficient.

It seems that there is no easy way to output both text and a figure at the same time currently. My current workaround is to split the text and figure output into two separate SRC blocks, not ideal but it works for me for the most part.

I think the idea for separating out text and image results is that usually print statements are used primarily for debugging which probably don't need to show up in a document. The issue seems to me to be about where print statements should show up in a document and where not. From my point of view including print statements in the output of a SRC block for then inclusion into a document is much more for scientific documents than for strict programming purposes where print statements are generally used for debugging. That being said I am interested in including both types of output. For this behavior, there does exist a open issue #157 about this. I suggest we move any further discussion of this to issue #157.