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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
26 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
63 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
25 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
23 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
30 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
51 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
37 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
38 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
39 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
28 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
23 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
0 votes
0 answers
17 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
14 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,668
0 votes
1 answer
24 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
0 votes
0 answers
39 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
56 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
194 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
40 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,707
0 votes
1 answer
52 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
  • 177
0 votes
0 answers
88 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
0 answers
73 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
16 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
30 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
1 answer
58 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
  • 499
2 votes
0 answers
183 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
17 views

python, open parenthesis at beginning of line inserts a space

Python code snippet (imin_f, jmin_f), (imax_f, jmax_f) = island_f non_overlap =set() n of non_overlab is behind ( , I can't tell which mode is doing it.. c-h k ( gives. ( runs the command ...
eugene's user avatar
  • 499
0 votes
0 answers
22 views

Prevent deletion of blank lines when tangling code blocks

The Python style guide asks for two blank lines surrounding class and function definitions (see PEP 8). When those blank lines are added in Org-Mode source blocks, they are removed during tangling. ...
Ben Bkhdt's user avatar
0 votes
0 answers
45 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
0 answers
34 views

Polymode in org-edit-special

I use (add-hook 'python-mode-hook 'poly-python-sql-mode) where poly-python-sql-mode is a special polymode that correctly highlights SQL queries that are used within strings in a Python file. When this ...
guibor's user avatar
  • 123
0 votes
1 answer
97 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
56 views

python source code with using realgud:gdb and pdb

Following invokes pdb in shell. I have to type list to look at the python source. Instead is there a way to open the python source file, just like how the c++ source file is opened when a gdb ...
user40923's user avatar
0 votes
0 answers
38 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
19 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
43 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
0 answers
50 views

Display Pillow image object in Babel Org Mode directly without saving into a file?

I wonder if there is any way for Babel in Org Mode to display images (from libraries like Pillow or matplotlib) "directly" without saving them into a file: #+begin_src python from PIL import ...
Daniel Krajnik's user avatar
0 votes
1 answer
98 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
42 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,035
3 votes
1 answer
249 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
183 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
160 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
104 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
  • 231
0 votes
0 answers
31 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
50 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
  • 209
3 votes
6 answers
355 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
133 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,231
2 votes
2 answers
323 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
0 votes
1 answer
36 views

How to move out of a python string with C-M-u

I'm used to using backward-up-list to go to the front of a string in most every programming mode, but for some reason it doesn't work in python-mode. python-mode rebinds C-M-u to its own python-nav-...
Cristian's user avatar
  • 233
1 vote
1 answer
59 views

Presenting Python function arguments in minibuffer for selection

I have written a Python function that takes a string input and performs a semantic search in my org-roam-directory and outputs the results in the following format after 2 seconds of computation: [{'...
user39819's user avatar

1
2 3 4 5
13