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.
630 questions
73
votes
5
answers
49k
views
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 ...
5
votes
1
answer
386
views
Emacs wrongly indent else expression in Python code
Say, I got a simple Python code snippet:
def demo(i):
if(i):
print "True"
else:
print "False"
I make indent-region for the whole buffer after save using before-save-hook in my ...
0
votes
1
answer
2k
views
Using TAB key for indentation in Python REPL produces strange indentation problems
I'm using the Python REPL in a comint window via the run-python command, and I'm seeing bad behavior when I use the TAB key to do my indentation. For example:
>>> for i in range(3):
... ...
3
votes
2
answers
586
views
Wrapping Python code with %cpaste and -- to send to iPython in elpy
I am loving my elpy setup in emacs, but I have one question. When I put in a ipdb.set_trace() for the ipython shell I want to send code snippets to the iPython shell. Right now my workaround is ...
3
votes
1
answer
367
views
Is it possible to transform emacs to something like bpython?
bpython detects what libraries are installed and has autocompletion for codes that weren't previously written in the text, if you ever used bpython you know what I mean.
Sometimes i use bpython ...
1
vote
0
answers
191
views
Evil-mode text objects not working in python.el's python-mode
This only happens in python-mode. When I try to use a text object to, for example, change everything inside or around some brackets (eg ci() it instead edits the first line of the file. So if I have ...
5
votes
0
answers
353
views
Ropemacs default refactoring
I'm performing a large python refactor, and one component of that is renaming many variables from camelCase to snake_case. I'd like to hook a camel-to-snake conversion function (which I already have) ...
1
vote
1
answer
287
views
Debugging a "binding stack not balanced" bug?
I'm trying to figure out how to approach a bug I've run into. I assume it's actually a bug in Emacs, but I don't know the right way to make headway with it. In short, I'm getting the message "binding ...
5
votes
1
answer
2k
views
Where is the python.el documentation?
I am using emacs-24.3, which comes with python.el and IPython support out of the box (or so they say).
Is there documentation for this mode? Where can I find it?
4
votes
2
answers
6k
views
Starting a virtualenv for emacs to use
I am starting a Python virtualenv through init.el (or so I would like):
(require 'virtualenvwrapper)
(venv-workon "my-python-project")
However, flycheck does not find flake8 or pylint, which are ...
1
vote
0
answers
34
views
Send pylint warning to bottom of list
When I'm using pylint-mode for a big refactor, I quite frequently want to banish lower-priority errors to the bottom of the buffer. Currently I have to skip the same errors ever time I refresh the ...
6
votes
1
answer
1k
views
Emacs 24's python.el + ipython cannot complete module names
I'm using Emacs 24.4.1 on OSX (installed with Homebrew), with the built in python.el, and Python 3 (also installed with Homebrew), along with IPython 2.3.0. I have this in my .emacs:
(setq
python-...
4
votes
1
answer
1k
views
Can't run Python shell in Emacs 24.4 due to a space in the path
When I try to start a Python shell in Emacs 24.4.1 running on Windows, I get an error "invalid argument" when Emacs tries to spawn the process. This is occurring because Python is installed under c:\...
3
votes
1
answer
202
views
Emacs 24.4 no longer highlights keywords in `M-x run-python`
With Emacs 24.3 I get certain keywords highlighted in an inferior Python buffer:
This is no longer the case for Emacs 24.4:
What could possibly cause this? I've made sure it's not my configuration by ...
5
votes
1
answer
771
views
UnicodeDecodeError in my Inferior Python buffer
While trying to run a python script in an Inferior Python buffer for Python 3.3.5 in my Emacs 24.3.1 GTK+ window, I get a
>>> Traceback (most recent call last):
File "<stdin>", line ...
7
votes
3
answers
2k
views
prettify-symbols-mode character replacement regex
I'm using the new emacs 24.4 prettify-symbols-mode, but it isn't behaving consistently.
I turn it on with:
(prettify-symbols-mode t)
(global-prettify-symbols-mode t)
And I'm trying to change the way ...
3
votes
1
answer
767
views
Python and aggressive-indent
I am trying to use aggressive-indent, which I find great, but when I am writing Python code it doesn't seem to work (although general it works fine). I may miss something in the usage of aggressive-...
3
votes
1
answer
1k
views
highlight breakpoints with pdb
I use pdb with gud to debug python scripts. I am just wondering if there is way to highlight the lines with breakpoints? For example, in some screenshots of gud-gdb, some people seem to have red ...
2
votes
1
answer
2k
views
Python mode - bypassing dialogue on C-c C-c, and having Python appear in its own frame
Whenever I'm in Python mode and do C-c C-c, I have to answer two questions - firstly, what command to run (which defaults to /usr/bin/python2 -i for me) and secondly, whether I want a dedicated ...
1
vote
0
answers
495
views
Python-emacs communication broken
When I call run-python, I get the buffer with python REPL and the prompt.
I can type stuff, but when I press enter there is no reaction (except the cursor moves in new line).
If I press C-c C-c (...
3
votes
1
answer
81
views
How can I enable my modifications to a library/package without modifying its source?
I have been using a forked version of python.el for some time in which I have changed the indentation rules so that instead of
something.method1()\
.method2()
and
stuff = (1, 2, 3,
...
11
votes
1
answer
4k
views
python auto indent problem
I'm using Emacs 24.4. When writing Python code, Emacs behaves strangely with respect to indentation.
For example:
for i in range(10):
print(i)
for i in range(10)
When I input :, Emacs adds a ...
18
votes
2
answers
5k
views
Display errors and warnings in an org-mode code block
I would like to be able to report warnings and errors when evaluating a Python code block in an Org file.
When a code block has Python syntax errors, Org helpfully pops them up in a separate ...
20
votes
2
answers
5k
views
Can I include a common code block in two different code blocks in Org mode?
I have an org-mode file containing a table of data and two Python code blocks to extract different summaries from it.
I would like to share some common constants and functions between these two code ...
7
votes
1
answer
5k
views
eldoc in python-mode
I'm trying to get eldoc-mode to work in python-mode. If I enter a python buffer and do
M-x eldoc-mode
M-x python-mode-switch-to-shell
This seems to work for some built-in functions, but mostly ...
18
votes
2
answers
1k
views
Make fill-paragraph in python docstring leave the triple-quotes on separate line
I type a python docstring all on one line like this:
"""
This is a long docstring. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas ...
3
votes
0
answers
303
views
Undesired auto expansion with company-mode and python-mode
I am using company-mode and python-mode (note the same issue does not happen with python.el) and something about the combination is causing emacs to automatically expand at point. For example, if I ...
7
votes
1
answer
2k
views
How can I prevent python-mode from occasionally highlighting everything as string
I use python-mode for my Python code, and every once in a while the syntax highlighter gets confused and thinks everything in the buffer is a string literal. This typically seems to happen when I ...
8
votes
2
answers
3k
views
Using virtualenvwrapper in Eshell
I noticed that I can't use virtualenvwrapper commands (like workon) in an eshell but they do work within a shell environment. Is there a virtualenvwrapper-like mode for Emacs?
11
votes
3
answers
3k
views
Emacs EIN vs IPython shell
I'm trying to make EIN work within Emacs, but right now (with IPython 2) it seems that it's not possible. This errors arise:
REQUEST [error] Error from parser ein:json-read: (json-readtable-error)
...