Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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.

197 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8 votes
0 answers
1k views

show output from python-shell-send-region

Using python.el and ipython.exe (from Miniconda3), I'd like to highlight a portion of code and execute it in the associated inferior python buffer. Example: #!/usr/bin/python3 myvar = 100+200 ...
r2evans's user avatar
  • 275
7 votes
0 answers
492 views

xref unsuccessful in python buffers: "no definition found"

The command xref-find-definitions is no longer working for me in Python buffers (with elpy-mode enabled. Its companions, such as xref-find-references, are also not working in Python buffers. ...
bashfuloctopus's user avatar
6 votes
0 answers
202 views

Incorrect filling of Python docstrings in pep257 mode

I have python-fill-docstring-style set to pep-257 (default) and I'm trying to fill docstring paragraphs. However, python mode does not count """ towards the number of characters, nor does it consider ...
Andrzej Pronobis's user avatar
5 votes
0 answers
120 views

Python development using Docker interpreter

I would like to use Spacemacs for Python development. I've used Emacs for years and still use it for org-mode and other note taking. At work we develop using Docker based interpreters. This means that ...
Anake's user avatar
  • 151
5 votes
0 answers
470 views

Emacs/realgud/Python: How to display variables at each step?

Using emacs and realgud one can have a separate buffer that automatically shows where the program is currently stopped (by displaying that line of source code). Is there an easy way to get realgud to ...
MikeTheTall's user avatar
5 votes
0 answers
2k views

Enhance python lsp-mode with elpy functions and keybindings

I've been using Elpy for a long time and have grown used to many of the default keybindings. I recently decided to give lsp-mode a go to see how it compares. I set it up following this blog and made ...
aiguofer's user avatar
  • 588
5 votes
0 answers
560 views

list of current variables in a buffer for Python code

I would like to find a way to reproduce the "Workspace" of Matlab or the equivalent "Variables" window of the awesome pudb debugger directly in emacs for python code: it is a window which details the ...
Robin Tournemenne's user avatar
5 votes
1 answer
926 views

Problem of starting a remote ipython console

I want to connect to remote ipython server, and follow the doc of the ipython, I start a ipython server in my server by ipython3 kernel -f ~/.ipython/kernel.json --pprint and I can start a ipython ...
Saddle Point's user avatar
5 votes
0 answers
334 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) ...
Matthew Piziak's user avatar
4 votes
0 answers
266 views

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 ...
Att Righ's user avatar
  • 775
4 votes
0 answers
343 views

Is it possible to debug Django from gud-pdb?

Brand new to gud/pdb and I am trying to run the Django development server from emacs. I can't seem to set breakpoints that affect the running server, though. I am invoking PDB with M-x pdb, then ...
Michael S's user avatar
4 votes
0 answers
188 views

How to connect to remote python with jedi.el?

How can I connect to remote python with jedi.el? I need to use remote virtualenv for getting possible completions, docs, etc.
sivakov512's user avatar
4 votes
0 answers
377 views

Org-babel and anaconda-mode in src blocks

I practice python literate programming with tangling to generate a full project structure. There are dependencies between modules and packages, and so I will say in the C-c ': #+begin_src python ...
Eric Kaschalk's user avatar
4 votes
0 answers
1k views

How to use the auto-completion of jedi while keeping other functions of elpy?

Currently, I have both elpy and jedi installed. init.el is like: (elpy-enable) (elpy-use-ipython) (setq elpy-rpc-backend "jedi") (add-hook 'python-mode-hook 'jedi:setup) (setq jedi:complete-on-dot t)...
purplezzh's user avatar
4 votes
0 answers
988 views

Org mode python session does not return a file name

In the following link you can find the following simple example: #+begin_src python :session :results file import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt fig=plt.figure(...
Dror Atariah's user avatar
3 votes
0 answers
74 views

org-babel python code block - not showing errors during execution

I have a python code block in an org-file that when executed results in some error. I was expecting to see that error in the #+RESULTS: block, but it doesn't show up. I have to navigate to the python ...
skittish's user avatar
3 votes
0 answers
181 views

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?). ...
Croad Langshan's user avatar
3 votes
1 answer
2k views

Autocomplete after dot in python

I haven't used emacs before, but would like to learn how to use it properly for Python development. From the past IDEs I have used I enjoyed the feature to obtain information on possible objects ...
Qohelet's user avatar
  • 185
3 votes
0 answers
1k views

debugging: how to optimize a RealGUD workflow

I code in Python and I my workflow uses debuggers (I coded for 8 years in Matlab). I develop numerical simulation codes: most of the time it returns a result, the question is: "Is the result right?" ...
Robin Tournemenne's user avatar
3 votes
1 answer
2k views

python "WORKON_HOME" not showing virtual environments in helm

I've check to see my WORKON_HOME env is set to where I want it at /home/user/anaconda3/envs but in helm the only option i get is .. if I select that option Emacs thinks my virtual environment is ...
zachatttack's user avatar
3 votes
0 answers
175 views

how to highlight imported functions in python code?

python-mode or elpy-mode in Emacs only highlight the basic Python library functions. If you work a lot with other libraries like numpy and matplotlib, would be nice to have these functions and ...
Nosferatu's user avatar
3 votes
0 answers
282 views

Automatically use appropriate Python version with Jedi.el

Documentation says that it can be done by making some variables buffer local. But how to make it correctly? Can somebody show me example how to configure this jedi.el behaviour correctly? Now I have ...
sivakov512's user avatar
3 votes
2 answers
2k views

elpy [No match] when installing package

I'm trying to follow the instructions in the README of this repo: https://github.com/jorgenschaefer/elpy . Everything goes smoothly until I get to the point where I am to install the package. After ...
user avatar
3 votes
0 answers
2k views

emacs as python IDE vs pycharm: spacemacs and code navigation

[2016.12.23]: I'm trying to make emacs be usable for working with python code. By 'usable' I mean I could rely on it with code navigation and completion. I'm using spacemacs + anaconda-mode for it, ...
mat's user avatar
  • 51
3 votes
0 answers
203 views

Org-babel noweb expansion when sending C-c ' buffer to python shell

I'm doing literate programming with Python. In my workflow I like to test the block with python-shell-send-buffer and ipdb debugger. However if the block contains a noweb reference then the code is ...
Eric Kaschalk's user avatar
3 votes
0 answers
433 views

Unexpected Indentation in Python interpreter

I am getting an indentation error in the Python interpreter while using elpy: >>> for i in range(1, 3): ... print(i) File "<stdin>", line 1 print(i) ^ IndentationError: ...
jsl's user avatar
  • 31
3 votes
0 answers
161 views

Remove extra prompts in inferior-python-mode with ipython

emacs24.5 -Q M-: (setq python-shell-interpreter "ipython") RET M-x run-python RET Python 3.5.1 (default, Dec 7 2015, 12:58:09) Type "copyright", "credits" or "license" for more information. ...
PythonNut's user avatar
  • 10.4k
3 votes
0 answers
105 views

Make fill-paragraph in *raw* python docstring leave the triple-quotes on separate line

This is almost the same question as this one, but not quite. I happen to like the docstring style def f(): """ docstring another line """ so in emacs I have python-fill-docstring-...
John Palmieri's user avatar
3 votes
0 answers
79 views

Indent parenthesized Python expression

I have emacs set up to indent Python code like so: foo( bar, baz ) That works fine. However, that style in a particular program I'm working on very often means I find myself with text like this:...
Croad Langshan's user avatar
3 votes
0 answers
350 views

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 ...
Hot.PxL's user avatar
  • 203
3 votes
0 answers
299 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 ...
noaham's user avatar
  • 181
2 votes
0 answers
184 views

How do i I use a virtualenv with pylint in flycheck?

I use pylint in flycheck via the python-flycheck plugin. By default it uses emacs's virtualenv which lives here: ~/.emacs.d/.python-environments/default on my machine. I would prefer if it used the ...
Att Righ's user avatar
  • 775
2 votes
1 answer
102 views

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 "&...
Connor Fuhrman's user avatar
2 votes
0 answers
102 views

No autocomplete in interactive python

OS: Windows 10 Emacs: 28.2 Python: 3.10 Package: elpy My init.el: ... (elpy-enable) ;; Use IPython for REPL (setq python-shell-interpreter "jupyter" python-shell-interpreter-args "...
simo hauml's user avatar
2 votes
0 answers
180 views

Unusual behavior in Python syntax highlighting

I have Emacs 28.1 installed via brew running on macOS Monterey. No further customization. When I open a very basic Python program, I get unusual syntax highlighting. See below for a screenshot; you ...
user38125's user avatar
2 votes
0 answers
411 views

Changes in python.el do not take place in python-mode

I'm facing the same problem as OP in this question: How can I make python-mode correctly indent python's match statement?. A quote from the OP: "Python 3.10 added a match statement. When I ...
Keyboard_Crasher's user avatar
2 votes
0 answers
718 views

`lsp` does not start on python-mode-hook

I am using lsp under Python.lsp does not start when a Python file is opened, I have to do M-x lsp for each file I open. Also when I switch from find-file to another file I have to do M-x lsp all over ...
alper's user avatar
  • 1,390
2 votes
0 answers
79 views

How to move by defun without moving up a level?

I am attempting to navigate methods in a file. Typically these are javascript or python files, which have a classes at the "top level", which in turn have methods nested within those ...
cammil's user avatar
  • 509
2 votes
1 answer
321 views

How could I see the output of my Python code in the echo area?

When I press C-c C-c(python-shell-send-buffer), I get output shown below. Afterwards when I do the same operation (C-c C-c) I always see Sent: #!/usr/bin/env python3... in the echo area. I just want ...
alper's user avatar
  • 1,390
2 votes
0 answers
471 views

flycheck - elpy - flake8 - ein and .ipynb files

I have set up Emacs (on Mac Catalina) with Elpy to handle Python. I also managed to get Jupyter notebooks (.ipynb files) working with Elpy via Ein. Both .py and .ipynb compile and use Flycheck ...
alpresci's user avatar
2 votes
0 answers
491 views

Jedi fails to start Jedi EPC Server because python 3.8 is installed and 3.7 not

Is the only solution to downgrade python 3.8 to 3.7 or wait till it is supported? Or are there other options? The error message is this: Error (jedi): ================================ Failed to start ...
topkek's user avatar
  • 89
2 votes
0 answers
512 views

What are the steps to set up elpy to use the anaconda python distribution on Windows?

I have anaconda installed on Windows (Windows 7), and it is working well in Jupyter. But of course I'd prefer to work in emacs. I have elpy installed in emacs, and it successfully sends commands to ...
Philip's user avatar
  • 21
2 votes
1 answer
385 views

Org-babel python with session breaks output

If I run the following code block: #+BEGIN_SRC python :results output print(" /|") print(" / |") print(" / |") print("/___|") #+END_SRC I get the result as expected: #+RESULTS: : /|...
Adam's user avatar
  • 1,897
2 votes
0 answers
179 views

Elpy auto-complete gives incomplete suggestions

I am trying to use Elpy for Emacs to write Python programs. The auto-complete feature suggests all attributes of PyQt5 classes, but suggests only a subset of the attributes of instances of these ...
Anders Buch's user avatar
2 votes
0 answers
190 views

Executing buffer twice in Python 3

I set up an environment to write Python 3 Code in my emacs (25.2.2) using python-mode and Elpy on Ubuntu 18.04. Strangely every time I use Python --> Send --> Execute Buffer the program is executed ...
Qohelet's user avatar
  • 185
2 votes
0 answers
295 views

Anaconda Mode only complete module variables, get No Matches for assigned variables on linux server accessed via ssh

Description Anaconda Mode only complete module variables, get No Matches for assigned variables on linux server accessed via ssh Reproduction guide Observed behaviour: - Start Emacs execute import ...
spacegoing's user avatar
2 votes
0 answers
68 views

C-c ' for editing all code blocks (to handle imports and variables)?

The Org manual says: C-c ' for editing the current code block. It opens a new major-mode edit buffer containing the body of the ‘src’ code block, ready for any edits. This feature is sweet. ...
kuzcoTheGreat's user avatar
2 votes
0 answers
61 views

fixing python-mode automatic line-breaks in the output?

I'm using emacs python mode to evaluate python (3.6) code and expressions. The mode (or emacs) seems to automatically break output lines at a certain length, even though my screen is wide enough to ...
tinlyx's user avatar
  • 1,364
2 votes
0 answers
1k views

Why are my .dir-locals not being applied even though they are loaded

Still on a never ending quest to get per project settings working for python using tramp and .dir-locals. Hitting a strange problem when I open a buffer I am asked if i would like to run my .dir-...
Oly's user avatar
  • 593
2 votes
0 answers
360 views

Lisp nesting exceeds max-lisp-eval-depth in python-mode 6.2.3, Emacs 25.2

I have this simple Python test program: #! /usr/bin/env python3 import numpy as np x = np.array([0, 1, 2, 3]) y = np.array([0, 1, 4, 9]) def gen_segments(x, y): for i in range(0, len(x)-1): ...
Håkon Hægland's user avatar