Skip to main content

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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
48 views

Setting correct flycheck checker with Python's poetry in Doom Emacs

I have a Python project managed with Poetry. Poetry creates virtual environments in ~/.cache/pypoetry/virtualenvs/ where all the dependencies are installed, including pylint. This means that if I want ...
Exercise To The Reader's user avatar
0 votes
0 answers
23 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, ...
jjk's user avatar
  • 748
0 votes
0 answers
31 views

Yasnippet returns Wrong type argument: listp

After inserting the snippet I'm able to type the function name. But after tabbing to args, I get the error Wrong type argument: listp on typing Is it python-args-to-docstring failing at it's job? I've ...
jjk's user avatar
  • 748
1 vote
1 answer
43 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 ...
Eric Auld's user avatar
  • 103
1 vote
1 answer
34 views

Emacs: elpy-shell-send-region-or-buffer is not using Python virtualenv

I am using GNU Emacs 29.3 on Windows 11 and have configured Elpy manually. I am a beginner in Elpy. It seems to be working as expected. I can see the auto-completion and documentation hints. However, ...
Amit Tendulkar's user avatar
0 votes
0 answers
65 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 ...
guibor's user avatar
  • 123
0 votes
0 answers
20 views

How to jump to a failed test while testing python?

I know this is a pretty broad question and maybe even non-emacs related. However I don't know where to start but develop python using dap-mode Usually I have two buffers: sometest.py and a terminal ...
jjk's user avatar
  • 748
0 votes
0 answers
28 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 ...
islam's user avatar
  • 1
0 votes
1 answer
131 views

How to evaluate python code in org-mode when only python3 is provided by the package manager?

Recently I started to use guix as my operating system. I installed python3 for my user via guix install python3. python itself is not available in the package repository, which I verified by running ...
Eldinur's user avatar
  • 13
0 votes
1 answer
22 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&...
beetlej's user avatar
  • 1,100
0 votes
0 answers
35 views

Python-mode code navigation

How can I navigate from an abstract class/method to the implementations of that class/method? Using the M-. I can jump to function definition but I can't find a way to easily find the implementation.
Isky's user avatar
  • 101
0 votes
0 answers
29 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 ...
ADS_Fibonacci's user avatar
0 votes
0 answers
67 views

Emacs Python Virtualenv Support

I am able to enable a virtual environment by adding these lines in .dir-locals.el in my project directory: ((python-mode . ((python-shell-virtualenv-root . "s:/.virtualenvs/default/")))) ...
Mehdi Khawari's user avatar
0 votes
1 answer
192 views

Install elpy on emacs

I checked the elpy site but came across an error where the package cannot be found? I am new to emacs and need a little help reading the error message. The specific code in the init file I tried to ...
Ranon's user avatar
  • 1
0 votes
1 answer
40 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 () "...
olivaw's user avatar
  • 151
0 votes
1 answer
52 views

Defining custom Python skeletons

I'm trying to define a custom Python skeleton and have found there are two macros in python.el that might be of use here. After poking around and looking at the value for python-skeleton-autoinsert it ...
slackline's user avatar
  • 345
0 votes
0 answers
56 views

Python parenthesis folding in doom emacs

I run into situations a lot where I have code that looks like new_stuff = ( blah.blah ( stuff, stuff, stuff, stuff, ).blah_two( [morestuff, stuffstuffstuff, stuffffff ] ) ...
Elle Najt's user avatar
  • 126
0 votes
0 answers
35 views

Python Code executes, but result screen shows a long line of characters

So my professor is obsessed with emacs and has encouraged us to set it up on our personal devices. Under his guidance I downloaded it, and he gave us some homework in a .org file. Inside this file, we ...
Timothy's user avatar
0 votes
1 answer
55 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 ...
Eric Auld's user avatar
  • 103
0 votes
0 answers
18 views

Org Babel: Open Python shell on session?

When I run an Org Babel shell code block with e.g. :session a header argument, it automatically opens a buffer a with the shell for this session, so I can explore it interactively. I love this feature!...
user42475's user avatar
0 votes
0 answers
16 views

The same code prints two different results from python

I wrote a sample code to print the same dataframe two times, but the first and second time print two different results: #+begin_src python :results output drawer import pandas as pd data1 = [['1','B',...
lucky1928's user avatar
  • 1,688
0 votes
1 answer
26 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-...
Eric Auld's user avatar
  • 103
0 votes
0 answers
47 views

fill-paragraph for Google style docstrings

When editing an existing docstring in Google style you need to call a function like fill-paragraph to cut the long lines while preserving the proper indentation. However fill-paragraph will not work ...
olivaw's user avatar
  • 151
0 votes
1 answer
76 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 ...
user17911's user avatar
  • 143
0 votes
1 answer
269 views

How to use eglot to set analyze path for python project?

I'm trying to use eglot on gem5, but I've noticed that I need to specify the analysis directory as src/python, and I understand that it seems to be possible to set this by setting eglot-workspace-...
Thysrael's user avatar
0 votes
0 answers
56 views

How to reliably use run-python with venv in buffer-env?

I have a python project using venv under PROJECT_FOLDER/.venv. I wrote an .envrc file there to activate the environment. buffer-env-describe seems to know about it. However, when I am in a python ...
wdkrnls's user avatar
  • 3,727
0 votes
1 answer
75 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 ...
J. Mini's user avatar
  • 123
0 votes
0 answers
118 views

how to turn off python formatting in emacs

I have a python program that I edit in emacs. However, sometimes when I save it, it gets re-indented, and in doing so, messes up the indentation of sections, where I have some code and then some ...
Christopher Clark's user avatar
3 votes
1 answer
139 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
0 votes
0 answers
20 views

Weird behaviour on emacs with running django server in terminal

something weird is going on in my 'emacs-IDE'. I am editing some javascript files in a django project using spacemacs. Some tools I use are treemacs and lsp-mode. In order to test my code I call up a ...
mor3dr3ad's user avatar
0 votes
1 answer
33 views

set the correct major mode for script files based on interpreter

I want to make a function that will set the correct major mode based on the interpreter used for a script. I don't want to include extensions in my scripts (because that can be annoying if making cli ...
Hackerman's user avatar
0 votes
2 answers
76 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) ...
eugene's user avatar
  • 519
2 votes
0 answers
212 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
0 votes
0 answers
52 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 ...
SLesslyTall's user avatar
0 votes
1 answer
112 views

Configure lsp-mode to start the python server when in snakemake major mode

I would like to know if it's possible to configure LSP mode to start the Python server when I work on a snakemake file (snakemake-mode), as I use heavily use Python in this mode also.
R-addict's user avatar
0 votes
0 answers
40 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 ...
geckos's user avatar
  • 151
0 votes
1 answer
23 views

change the tag of the exported code

I want to change the exported tag of #+begin_src python .. #+end_src exports to \begin{verbatim} ... \end{verbatim} I want it to be export to \begin{python} \end{python} Anyone has any idea ?...
barak diker's user avatar
0 votes
0 answers
44 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 ?
Dilna's user avatar
  • 1
0 votes
1 answer
127 views

Using emacs for learning python with numpy

I would like to use emacs for learning python with numpy. How can I proceed ? Have seen other using Jupyter but would prefer using emacs instead. Would it be possible to have a simple example using ...
Dilna's user avatar
  • 1
0 votes
1 answer
49 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 ...
scribe's user avatar
  • 1,055
3 votes
1 answer
291 views

python-shell-completion-complete-or-indent (Tab, in an inferior python mode shell) completes "__PYTHON_EL_eval_file"

On Emacs 29, Python 3.11.3, IPython 8.13.2 A strange behavior seems to have recently started. When opening a python shell with run-python and then python-shell-send-buffer or python-shell-send-file ...
Metropolis's user avatar
1 vote
0 answers
230 views

Eglot/pyright on Windows is sending malformed paths to the server

I'm getting all kinds of strange behavior trying to run Eglot with Pyright on Windows with Emacs 29.0.60 ((build 1, x86_64-w64-mingw32) of 2023-03-10). The *Messages* buffer shows lots of attempts to ...
Rodney Price's user avatar
1 vote
1 answer
174 views

Why doesn't the ##* outline work with Python?

I have the following configuration for outlines in my init.el file: (defvar my-outline-regexp-alist '((emacs-lisp-mode . "\\s-*;;\\*+") (js2-mode . "\\s-*//\\*+") (...
raylight's user avatar
  • 237
1 vote
1 answer
124 views

Emacs 28 crashing when using triple quotes for docstrings

In Emacs 28, in python-mode, unbelievably, triple quotes causes emacs CPU utilization to hit 100% and freeze / crash. Apparently a known error related to jit-lock-mode. I'm asking the question here, ...
Marc Cenedella's user avatar
0 votes
0 answers
30 views

`run-python` cannot hide *Python* buffer

When running (defun my/run-python () (interactive) (let ((buf (current-buffer))) (with-current-buffer buf (save-mark-and-excursion (run-python (python-shell-calculate-...
phoxd's user avatar
  • 241
0 votes
0 answers
33 views

Inferior Python mode seems to redirect some output back as input. How to fix?

I'm running a Python3 REPL in Inferior Python Mode. When user input follows directly after some output, the next output seems to be redirected to the REPL, interpreted as user input, and evaluated. ...
henning no longer feeds AI's user avatar
0 votes
1 answer
55 views

do nothing more than syntax highlighting when spacemacs open python file(or any other source files)

I use spacemacs. Currently, when I open a python file, emacs will do a lot of things, it will check the syntax and give tips. This is what describe-mode gives: Auto-Compression Auto-Encryption Bug-...
Tokubara's user avatar
  • 219
3 votes
6 answers
429 views

__PYTHON_EL_eval_file prints in interpreter when sending python file from buffer using C-x C-l

Whenever I send the a Python buffer to the interpreter via C-x C-l it prints the file eval call as shown below. While it does print the correct output, it's a bit annoying to see it every time and I'd ...
Ricardo's user avatar
  • 131
2 votes
2 answers
148 views

Python-mode Multi-line Conditional Indentation

Given the following somewhat silly Python code with a multi-line condition: if ("VALUE" in my_uncessarily_long_dictionary and some_other_long_condition_case): do_something() else: ...
Xaldew's user avatar
  • 1,261
2 votes
2 answers
364 views

IPython doesn't echo code input

Typically when I send code from a Python script using C-c C-e to IPython, IPython does not echo the code that I input. For example, sending a script with just the following in test.py 2 + 2 and ...
cdd's user avatar
  • 217

1
2 3 4 5
13