I will work on getting more details this weekend. It looked like the buffer passed to org-babel-comint-wait-for-output was missing the "earmuffs". I tried adding the earmuffs with the org function for that but although I got passed that error, I messed up my python session and the following python blocks were not aware of the imports in the first block. Mark I tried something that was suggested last September 14th by Augusto Stoffel. I had not tried it because changing the sleep from 10 to 90 was my workaround. One thing that might work is to block until the shell is ready with something like (run-python) (with-current-buffer *the-shell-buffer* (while (not python-shell--first-prompt-received) (accept-process-output (get-buffer-process (current-buffer))))) The patch that is working for me now is: modified lisp/org/ob-python.el @@ -198,7 +198,10 @@ org-babel-python-initiate-session-by-key (let ((python-shell-buffer-name (org-babel-python-without-earmuffs py-buffer))) (run-python cmd) - (sleep-for 0 10))) + (with-current-buffer py-buffer + (while (not python-shell--first-prompt-received) + (accept-process-output (get-buffer-process (current-buffer))))) + )) ((and (eq 'python-mode org-babel-python-mode) (fboundp 'py-shell)) ; python-mode.el (require 'python-mode)