Questions tagged [python]

use for Python programming language in Emacs. Emacs supports several versions of the language implementation, versions, and coding styles. Python questions should augment with additional tags as appropriate as described in the description below.

Emacs already has out-of-the-box Python support via python-mode and there are a number of Python major modes for Emacs. Emacs provides basic editing and IDE-like features by using a combination of native Emacs features and external Emacs/Python packages:

  • python.el comes with Emacs versions 24.2 and later
  • python-mode.el
  • loveshack python.el for Emacs versions 24.1 and before

When tagging questions with , mention Emacs and Python package versions.

For IDE-related questions, mention which of these packages as well:

  • Elpy
  • anaconda-mode
  • Spacemacs Python layer, which is based on anaconda-mode
  • python-mode.el, which replaced python-mode in python.el

Questions about Python interactive shells and REPLs should tag them with as well.

621 questions
70
votes
5 answers

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

Emacs is an excellent editor - however it is said "to program you first need an IDE" - so how would you build an IDE in the extensively customizable Emacs for PYTHON with all the features of modern IDE. I want to be able to effectively debug, run…
Serial Exchangist
  • 851
  • 1
  • 7
  • 7
12
votes
3 answers

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

I'm interested in using languages other than elisp to write emacs extensions, is this possible at all? If python is not supported, what languages are?
nukeop
  • 133
  • 1
  • 5
12
votes
3 answers

Two Python modes

I have been trying to configure Emacs to use the proper Python mode. To this end I have read a few tutorials. Most importantly this one. The tutorial uses the python-mode package. However, when I install it through the package manager (M-x…
10
votes
3 answers

Specifying python version in run-python

I'm trying to figure out how to specify which version of python to run when calling "run-python" (C-c C-p) in python-mode, and I've run into the following problem. These are the first few lines of the definition of run-python: (defun run-python…
user17376
10
votes
1 answer

How can I make fill-paragraph regard the formatting rules of Python docstrings?

If I press M-q in a docstring like this, then the line breaks in the docstring get messed up: def foo(word): """ This is a function that does something. @param word: str, input. @returns: True """ becomes this def foo(word): """This is…
Lenar Hoyt
  • 1,173
  • 7
  • 25
9
votes
1 answer

How do I disable python-help

I just upgraded to Emacs 26.1 on Linux (Ubuntu 18.04, but emacs26 from the kelleyk repo). python-mode is now bringing up a *Python-Help* window whenever the cursor in on a symbol or keyword. I'm finding this very distracting because it messes with…
Dan Christian
  • 241
  • 1
  • 7
9
votes
2 answers

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

My system is macOS and I have both python 2 and 3 installed. I am currently working on a side project for which I want to use Django 1.8 and python 3.4. I have created a virtual environment with the python 3 command pyvenv venv in the parent folder…
Napoleon
  • 237
  • 1
  • 4
  • 9
9
votes
3 answers

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

I'm using C-c C-c to send a buffer to a Python shell. The buffer has an import at the beginning. I found that if I modify the module I'm importing, it doesn't reflect the changes if I run the buffer again with C-c C-c (it seems the Inferior Python…
El Diego Efe
  • 1,621
  • 1
  • 19
  • 24
5
votes
2 answers

Python-mode: Eval-Buffer [C-c C-c] doesn't run my script

Here are my steps: 1- Switch to Shell C-c C-z 2- Click enter to accept 3- Eval-Buffer C-c C-c to run the script I just got the following message: sent: #!/usr/bin/env python... Running Eval-File works fine. It's just Eval-Buffer what doesn't…
RafaelGP
  • 301
  • 2
  • 6
4
votes
0 answers

Python automatically add import statement

Is there a way to automatically add imports to python code within emacs? def f(x: str) -> List[str]: I want to be able to have my guess over "List" press a key binding and magically add List to my imports. I had a brief look on github, didn't find…
Att Righ
  • 775
  • 4
  • 14
3
votes
0 answers

See mypy type of what's under point

Is it possible to see mypy types in emacs? I would like a command that does something like show the type of what's under point (presumably getting that information from the mypy cache for speed?). Or alternatively, I might be happy with a UI like…
Croad Langshan
  • 3,332
  • 18
  • 44
3
votes
2 answers

How can I make python3 the default in Emacs 25.2.1?

I do have python3 on my laptop. $ sudo find / -name "python3" | python3-locations.org (partial list of…
dagmarPrime
  • 131
  • 2
3
votes
0 answers

Set up Jedi with virtualenvwrapper

I'm using a virtualenvwrapper setup for Python. On my emacs, I have virtualenvwrapper and jedi installed from MELPA. What I currently do is, I open Emacs, M-x venv-workon RET blabla RET, then M-x jedi:setup RET. Now I have Numpy installed in…
Hot.PxL
  • 203
  • 1
  • 5
2
votes
1 answer

How to temporarily disable smart-operator?

I am using smart-operator for Python programming, and I like to use it. However I have also found it annoying for inputting: regular expressions like .* equals (=) in an function. I would like to disable it by a prefix shortcut, is there any way…
Coeus Wang
  • 123
  • 3
2
votes
1 answer

Python mode hangs on class member comment

Emacs is freezing when trying to insert a class attribute comment when it's not at the end. E.g., class Foo: _bar: int """Some attribute.""" _biz: int """Another attribute.""" I cannot edit the above to create the below class Foo: …
1
2 3 4