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
1
vote
1
answer
55
views
Python package installation and pyvenv
I use pyvenv to create new environments and activate them. I, sometimes, use libs that are not in standard lib, and I usually have to install them with pip3 module/command.
For example, to install ...
1
vote
1
answer
93
views
TextIOWrapper error when trying to pass strings between Python session code blocks
This worked seamlessly, but at some point, I lost the ability to pass string-type variable values between code blocks in Org Babel.
Let’s take the following example:
#+begin_src python :session *PY* :...
0
votes
0
answers
37
views
Getting a start-process: Spawning child process: Exec format error while running python (elpy)
I'm running python 3.12 at work on windows using emacs as IDE. At home I'm running linux where my setup works without any issue. However, at work with windows I struggle to get it properly run.
I have ...
0
votes
1
answer
284
views
Indenting Python multiline argument lists like Black/Ruff
I want to configure Emacs to indent multiline argument lists in Python like Black or Ruff (4 spaces before each argument), but Emacs is very insistent on following PEP-8 (8 spaces). Even if I manually ...
1
vote
0
answers
55
views
Python command works in term but doesn't in eshell
I'm trying to run a python script using selenium (that should call the executable geckodriver, installed) but, while the script runs in term, it errors in eshell (and in the python console).
A minimal ...
1
vote
0
answers
27
views
Output from evaluating python source code blocks in org-mode not correct [duplicate]
After switching to Mac from Windows, the output of my python org-mode code blocks are not working properly. It keeps printing what seems to be the backend python call instead of the code output. And ...
0
votes
0
answers
121
views
how to configure and use dumb-jump
I have following in my init.el file:
(use-package dumb-jump
:straight t
:init
)
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate)
(setq xref-show-definitions-function #'xref-show-...
1
vote
1
answer
168
views
org-mode not producing plots with python source blocks
I'm trying to use org-mode to knit a document with some text and plots produced with python. However, when I export the org file to html or pdf, it doesn't output the plots, only the text and code.
I ...
0
votes
0
answers
80
views
How to auto indent?
Say I'm in foo.py and I want to paste something into the docstr of function f:
something:
foo
bar
def f():
"""
"""
My current workflow (evil normal mode, ...
2
votes
1
answer
255
views
Python Org Babel producing garbled result
I have the following settings on for org-babel
#+PROPERTY: header-args:python :python ~/env/pt/bin/python :session a :results drawer output replace
When I evaluate a code block, the results are some ...
3
votes
0
answers
379
views
How to jump to definitions in different modules using `eglot`
I am using eglot (have tried both pyright and pylsp).
Jumping to definition at point works, but when I select a variable imported from a different package, or the package itself, nothing happens.
For ...
0
votes
0
answers
38
views
every time I run python code I get message sent: and the first line
hello I am trying to run python application on Emacs as an IDE I installed pyel and pyright from pip and package installer but now some time the result is showing and sometime it is not trying to push ...
0
votes
1
answer
34
views
use output of python code block from other python code block
My emacs is 29.2 in linux. I try below code to use output from first python block, but the output in second block is None after press C- C-c.
#+name: testblock
#+begin_src python
print("hello&...
0
votes
0
answers
57
views
Org Mode Code Sessions Scope
I'm trying to use sessions within an org file to keep the code workspace as I need something similar in style to the Jupyter Notebooks. The issue I'm having is this isn't restricting the session to ...
0
votes
1
answer
69
views
fill-region fails as fill-forward-paragraph complains about argument type
I am trying to fill a region within a Python docstring. The function find-docstring-limits returns the limits of the docstring. Here is the function:
(defun indent-docstring-paragraph ()
"...
0
votes
1
answer
173
views
Org Babel: Possible to get Python shell with session?
When I make an Org Babel shell code block with for instance a :session a header argument, it automatically makes a buffer a with the shell for this session, so I can explore it interactively.
This is ...
0
votes
1
answer
81
views
In Python buffer erase large output
Python buffers support comint-delete-output, but if I forget to do it before entering another command, I have a big hunk of text I can't easily erase.
In shell mode, I can set the mark and run comint-...
0
votes
1
answer
187
views
No output in Python inferior buffer after C-c C-c
OS: Windows 11 (64 bit)
Python version: 3.12.0 (64 bit)
Emacs version: 29.1
I use LSP mode in Emacs for Python programming and I have in my Emacs init.el file the following:
(custom-set-variables
...
0
votes
1
answer
155
views
Why does adding a return value to my Python code stop it from printing?
Load up Emacs in the default modes, i.e. emacs -Q. After this, make a new .Org file with the following contents and run the Emacs Lisp code.
(setq org-babel-python-command "python3")
(setq ...
4
votes
2
answers
361
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 ...
0
votes
3
answers
157
views
add a new line with the same indentation level as the current line
when python code block gets larger, it's hard to find the right indentation level
def foo():
for a in l: # l1
# l1-1
for b in k: # l2
print(a)
# (2)
print(b)
...
0
votes
0
answers
73
views
Bad closing bracket indentation for electric-pair in python
I am getting the wrong indentation for closing braces when I use electric-pair mode in python.
For example, if I place the cursor (|) like so :
for i in range(10):
foo = [|]
and hit return, then ...
0
votes
0
answers
54
views
company-mode with python inserts weird characters
Company mode suggests the right completions, but when I press RET I get weird characters, probably denoting the position, I was expecting to be able to cycle between each of these spots with tab or at ...
0
votes
0
answers
66
views
auto-mode-alist for python files
Am doing the following for org files.
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
What should I do for python ?
0
votes
1
answer
102
views
OSC 8 links not working in the Comint mode
According to the NEWS for Emacs 28.1 (Ctrl-f "OSC 8, for hyperlinks"), the comint-mode supports the OSC 8 styled links. But when I compile (interpret) a file "test.py" with ...