Hot answers tagged

66 votes

How do you create a robust Python IDE with Emacs (as the Text editor)

The default Python mode in Emacs has a number of features, including code completion based on the inferior Python shell, so that can be used as a basic IDE without any added packages. You can use ...
user avatar
24 votes
Accepted

Python org-mode source block output is always ': None'

This is a peculiarity of how babel handles some languages. This gives some detail on python, and a complete list of options is available here. There are quite a few useful ones. Basically, depending ...
user avatar
  • 2,081
23 votes

How to set up elpy to use python3?

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 ...
user avatar
23 votes
Accepted

Using conda environments in emacs

I'd suggest using pyvenv library, it provides a neat interface to selecting a virtual env among several alternatives updating interpreter and library paths. You will need to alter WORKON_HOME variable ...
user avatar
  • 524
21 votes

Python org-mode source block output is always ': None'

In a very simple case like this one, there's a hack I tend to use, replace print with return: #+BEGIN_SRC python return "hello" #+END_SRC #+RESULTS: : hello But in general the better solution will ...
user avatar
  • 2,753
18 votes

How do use Emacs to look up a function in Python?

Did you try Elpy? It binds elpy-goto-definition to the key M-.. If you have a recent Emacs, I think you can also jump back with xref-pop-marker-stack (M-,). Elpy has some other nice features as well. ...
user avatar
  • 1,683
17 votes

How do you create a robust Python IDE with Emacs (as the Text editor)

I would encourage evil-emacs users to try spacemacs. It has a brilliant python-layer, see the details here: https://github.com/syl20bnr/spacemacs/tree/master/layers/!lang/python As of now, it ...
user avatar
17 votes
Accepted

python auto indent problem

This is caused by electric-indent-mode, which is enabled by default in Emacs 24.4. You can turn it off with (electric-indent-mode -1) If you don't want to disable electric indent mode entirely but ...
user avatar
  • 6,434
17 votes
Accepted

Can I include a common code block in two different code blocks in Org mode?

You can do this most easily using org-babel's noweb reference syntax for literate programming. Here is an example: * Initialization block containing function definition #+NAME: init_block #+...
user avatar
  • 2,735
15 votes
Accepted

org-mode: how can i point to python3.5 in my org-mode doc?

I discovered that just setting in the file: ~/Library/Preferences/Aquamacs Emacs/Preferences.el (setq org-babel-python-command "python3") Does the job. However, i don't really understand why it ...
user avatar
  • 471
14 votes
Accepted

How to automatically run inferior process when loading major mode for the first time?

FYI, some modes open only one inferior processs. For example, run-python will open an inferior process only if there isn't already an inferior process running. What you suggested with run-python ...
user avatar
  • 1,683
13 votes
Accepted

Where is the python.el documentation?

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.
user avatar
  • 7,298
12 votes

How do use Emacs to look up a function in Python?

I use Jedi mode for Python and I'm very happy with it. Not only does it do accurate look ups for function calls, it resolves functions to the correct definition even in complicated situations (like ...
user avatar
12 votes
Accepted

Two Python modes

Well yes there are two python modes: the one which ships with emacs is python.el and the other one is python-mode.el which is indeed this one: https://launchpad.net/python-mode Your tutorial has been ...
user avatar
  • 1,831
12 votes
Accepted

Library for automatically inserting python docstring in Google style

Package The code described in the following section have now been made available in a separate package. Please see this repository for details: https://github.com/Xaldew/yasnippet-radical-snippets. ...
user avatar
  • 1,231
12 votes

Your ‘python-shell-interpreter’ doesn’t seem to support readline

If you don't want to get a 25.2 rc, you can apply the bug fix by adding this to your init.el file: (with-eval-after-load 'python (defun python-shell-completion-native-try () "Return non-nil if ...
user avatar
  • 8,793
11 votes
Accepted

Which class or method or function am I in?

which-function-mode displays the current method name. The following configuration, which I got from Emacs Redux, displays the current method / function / orgmode heading in the top header line rather ...
user avatar
  • 5,005
11 votes

Exporting highlighted source code to pdf in Org-Mode

Hey this answer solved my similar problem. A bit late but I had the same issue today. As mentioned, I add the following code snipped to my .spacemacs/.emacs config: (require 'org) (require 'ox-latex)...
user avatar
  • 221
11 votes
Accepted

How to highlight in different colors for variables inside `fstring` on python-mode

I think this will do it for Emacs versions < 27.1 (require 'python) (setq python-font-lock-keywords (append python-font-lock-keywords '(;; this is the full string. ;; group ...
user avatar
10 votes

How do use Emacs to look up a function in Python?

The feature of PyCharm that you mention was one of my favourites, and one of the first things I looked for in trying to replace PyCharm completely with Emacs (which I am happy to say I have been able ...
user avatar
  • 4,535
10 votes
Accepted

How to force a Python shell to re-import modules when running a buffer?

You can explicitly reload a module like so: import mymodule import imp imp.reload(mymodule)
user avatar
  • 3,276
10 votes
Accepted

Is there a way to use python instead of elisp for extending emacs?

As Tephra said, Pymacs is a package designed for this. It's an interface between Python and Emacs Lisp. The project isn't very active but from what I understand it's fully functional with the latest ...
user avatar
  • 929
9 votes
Accepted

Display errors and warnings in an org-mode code block

As described by Eric Schulte on the org-mode mailing list (see the link in the question) we can modify org-babel-eval to achieve this: (defvar org-babel-eval-verbose t "A non-nil value makes `org-...
user avatar
  • 8,952
9 votes

Emacs EIN vs IPython shell

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 ...
user avatar
9 votes
Accepted

How do I get Emacs to recognize my python 3 virtual environment

There is a package called pyvenv to manage virtual environmnets in emacs. Try installing it with `M-x package-install RET pyvenv RET` Now You to activate env in your emacs, You can run M-x pyvenv-...
user avatar
9 votes
Accepted

Multiple major modes in one buffer (e.g., python-mode & LaTeX-mode)

MMM-mode (multiple major modes) seems exactly what you're looking for. It is mentionned on the emacs wiki. You need to define a submode class to mix LaTeX and python, specifying that python parts ...
user avatar
  • 6,973
9 votes
Accepted

Spacemacs use anaconda environment

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/<...
user avatar
8 votes

eldoc in python-mode

The default eldoc integration of python.el will show functions defined in the Python shell. If you send the definition of your function to the Python shell in Emacs, eldoc should also show information ...
user avatar
8 votes
Accepted

how to remove the red underline

When you spot a problem in the way how emacs behaves and if that happens only when you load your emacs config (init.el or .emacs) and not when you run emacs -Q, you need to bisect your init to find ...
user avatar
  • 24.3k

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