Hot answers tagged

41

IPython 5 has a new terminal interface, which is not compatible with Emacs' inferior shells. To fix it, add the --simple-prompt flag to the IPython command: (setq python-shell-interpreter "ipython" python-shell-interpreter-args "--simple-prompt -i") From the documentation: The new interface is not compatible with Emacs ‘inferior-shell’ feature. To ...


14

You can conffigure elpy-rpc-python-command. If you want Python3 you can set it like this. (setq elpy-rpc-python-command "python3") Update Create python3 virtualenv using virtualenvwrapper from terminal $ mkvirtualenv test -p /usr/bin/python3 and then install required packages $ pip install rope jedi importmagic autopep8 flake8 Now go to emacs, ...


13

You can visit the file python.el.gz which defines the mode doing M-xfind-libraryRETpythonRET. The commentary at the beginning of the file is pretty comprehensive.


9

You are correct that ein at tkf's repository on github only works with versions of IPython prior to 2.x. With that said, however, if you use this version you will find that it works with IPython 2.x and Jupyter (i.e. IPython 3.0). Installing ein from MELPA or el-get will install the latest ein which works with the latest versions of IPython.


9

Basically, this is a duplicate of this question. Reproducing the proposed behavior with spacemacs, I changed my user-init to: (defun dotspacemacs/user-init () (setenv "WORKON_HOME" "/home/<username>/.local/bin/anaconda3/envs") ) After reloading my .spacemacs file with SPC f e R, I'm immediately able to use , V w and select environments from my ...


5

Yes, that's possible. Add the following code to your init-file (note that you might have to adapt /usr/bin/ipython2 and /usr/bin/ipython to point to appropriate executables for IPython 2 and IPython 3, respectively): (defun run-python2 () (interactive) "Run IPython with Python 2." (let ((python-shell-buffer-name "Python 2")) (run-python "/usr/bin/...


5

I don't use eply, I use emacs 25.1.1 with company-jedi with the following: (setq python-shell-interpreter "ipython3" python-shell-interpreter-args "--simple-prompt --pprint") Inside emacs *Python* Python 3.6.0, Anaconda 4.3.0, Ipython 5.1.0 In[1]: x = 10 In[2]: x = 125 In[3]: x = # type M-p I get history items 1 and 2 and Input restored. That ...


4

How to Debug? It's tough to spot until you know what you're looking for, but in the middle of the stacktrace you see that the byte-compiled functions are calling python-shell-completion-get-completions. You can step through this function with edebug to see what's happening, or you can appeal to divine inspiration to conclude that it ultimately sends the ...


4

I think EIN's main value was to be able to connect arbitrary buffers to the ipython kernel that corresponds to the notebook, therefore enabling cooperation of multiple Emacs "objects". But since EIN's README only mentions ipython 0.12 and there hasn't been any activity for a while, it's highly likely that API changes make it currently unusable.


4

You can solve this by modifying the python shell configuration from python to python3 in elpy-config M-x elpy-config to enter the configuration page of elpy if you scroll down you will see groups with [+] signs, toggle the Python one and find the shell interpreter option: Option Python Shell Interpreter is the one you are looking for. If you click (or Enter ...


4

Reading the docstring for the deprecated elpy-use-ipython, it points to https://elpy.readthedocs.io/en/latest/ide.html#interpreter-setup that recommends the following setup for ipython: (setq python-shell-interpreter "ipython" python-shell-interpreter-args "-i --simple-prompt") If it still fails, you could try using full path to your ipython ...


3

Check the arguments that run-python requires, and supply them in your hook function that calls it (use a lambda with interactive or a named command that you defined). Otherwise, if you want to interact with it then use call-interactively in the mode-hook function.


3

You need to add the function comint-truncate-buffer to the hook comint-output-filter-functions, like so: (add-hook 'comint-output-filter-functions #'comint-truncate-buffer) By default, the buffer will be truncated at 1024 lines. To change it to 1000 you will need to change the variable comint-buffer-maximum-size, like so: (setq comint-buffer-maximum-size ...


2

The problem is that you cannot directly paste code into an ipython session. A post on the Org mailing list by Arun Persaud gives a workaround that employs the %cpaste magic command. Here is a slightly simplified version: #+BEGIN_SRC emacs-lisp ; use %cpaste to paste code into ipython in org mode (defadvice org-babel-python-evaluate-session (around org-...


2

I realize it's an old question, but since it was left unanswered, I will bring the fix I found here after running into the same issue. Make sure your version of IPython is at least 5.4 Install rlipython (sudo pip install rlipython) Run IPython and then run inside import rlipython; rlipython.install() And that's it. All the best!


2

Not sure which ipy mode, You are referring. I use ipython shell which comes with elpy. It also has the same problem. By default up arrow (or M-p) are bind to (comint-previous-input ARG). So no matter what You have at cursor, it just shows the previous input. There is another function called (comint-previous-matching-input-from-input N) which basically ...


2

I believe the line should be (require 'ein)


2

this was discussed on the emacs-ipython-notebook github recently. https://github.com/millejoh/emacs-ipython-notebook/issues/41 It seems like a bug in iPython, but for the moment there is a work around by setting the matplotlab rc parameters directly. import matplotlib as mpl mpl.rcParams["figure.facecolor"] = "white" mpl.rcParams["axes.facecolor"] = "white"...


2

It looks like adding (package-initialize) (require 'ob-ipython) to my .emacs solved the problem!


2

You need to update org-babel-load-languages. Try this: (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t) (ipython . t))) This is described in the Org Manual


2

ipython 5.0.0 by defautl uses prompt_toolkit which is really nice in a terminal but uses special characters for colors and completion that screws emacs display. Eventually it should be fixed but for now I have this in my .emacs: (setq python-shell-interpreter "ipython3" python-shell-interpreter-args "--simple-prompt --pprint") and run M-x run-...


2

This doesn't seem to be a problem with python-mode but with your python instance. This link goes into more detail, but it boils down to something has crashed. From the description you've given it sounds like your python instance is the crashing element. Double check that your python installed right. Considering that it is ubuntu, it should be fine. Next ...


2

Elpy doesn't require emacs jedi package. Also they won't work well when both are configured. I guess there is some conflict between them. Use only elpy and you should be able to get completion in rpc buffer. I created an empty file with class Foo: this = 2 After sending this to python buffer with C-C C-c, if i switch to python buffer and type Foo. ...


2

The links you were reading are mostly about macOS and/or Emacs 25.1 and earlier. Unfortunately, the "native" completion won't work under Windows, as it lacks PTYs. So you should do (setq python-shell-completion-native-disabled-interpreters '("python")) to suppress the warning, and accept the "fallback" completion method without further noise.


2

OK, so I figured this out (thanks largely to this answer). Now, rather than simply typing C-c C-p, I use C-u C-c C-p to get the options of specifying the Python command I want, and to select a dedicated interpreter. Because I use dedicated shells so often, I created this fn: (defun my-python-start-or-switch-repl (&optional msg) "Start and/or switch ...


2

Nathaniel Nicandro has recently released his emacs package jupyter to further integrate org-mode with jupyter. As mentioned in the readme: emacs-jupyter extends the features of ob-ipython by integrating more with org-mode and providing a better REPL interface to the kernel.


2

Your example works perfectly in my setup. First make sure ipython-ob is included in the babel-languages: in my case: (org-babel-do-load-languages 'org-babel-load-languages '((python . t) (ipython . t) (ledger . t) (latex . t) (clojure .t) (shell .t) )) THEN display images online added to your init file: (add-hook 'org-babel-after-...


1

You can try setting the python interpreter to ipython with: (setq org-babel-python-command "ipython") And then just use python with begin_src: #+BEGIN_SRC python :session myip %matplotlib inline import matplotlib.pyplot as plt import numpy as np #+END_SRC


1

Actually, the problem seems to be on the iPython side. Upgrading to 5.1.0 fixed the problem, both with Anaconda iPython or MSYS2 iPython.


1

You could hook into before-change-functions: (add-to-list 'before-change-functions #'(lambda (_b _e) (goto-char (point-max))))


Only top voted, non community-wiki answers of a minimum length are eligible