2022 Developer Survey is open! Take 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
1 answer
39 views

Unable to setup lsp-mode with lsp-pyright

I'm using Emacs 28.1 on macOS 11.6.6 (installed with brew) and want to setup a Python IDE with lsp-mode and lsp-pyright. My (not full) init.el looks like this (LSP and Python setups are at the bottom ...
user avatar
1 vote
0 answers
16 views

pylsp times out over TRAMP

I'm (unfortunately and against my will) using Windows 10 running Emacs 28.1 attempting to connect to a remote Ubuntu machine via TRAMP (currently this happens to be WSL but there are other Linux ...
user avatar
0 votes
0 answers
20 views

py-autopep8-enable-on-save is deprecated! use [py-autopep8-mode] instead!

I'm getting the message py-autopep8-enable-on-save is deprecated! use [py-autopep8-mode] instead! in the messages on startup. How to properly update it? GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, ...
user avatar
  • 153
0 votes
1 answer
21 views

How to enable terminal beeping?

xterm conviniently beeps on a failed unit test (pytest): Beeping (start-process "" nil "/usr/bin/xterm" "-e" "python3" "-B" "-m" "...
user avatar
  • 607
0 votes
0 answers
21 views

LSP Jedi server error

I've hit some trouble with lsp-mode and in particular lsp-jedi. I have my virtualenv selected under Emacs using pyvenv-workon and jedi-language-server is installed under the virtual environment. At ...
user avatar
  • 251
0 votes
0 answers
21 views

Call a function and all relevant hooks inside a function

I have a function consisting of 2 commands. (defun my-function () (interactive) (call-interactively 'run-python) ; <-- Something is not run after this line. (call-...
user avatar
  • 191
0 votes
1 answer
46 views

org-mode batch export hangs when using a python session

I have developed a workflow for batch-export of org-mode files, and have come across an issue in which execution halts when using a python session. I'm using emacs 28.1 on MacOS 11.6.5 with Python 3.9....
user avatar
0 votes
2 answers
33 views

Activate origami folding for python only with using use-package

I want to activate origami folding mode for python only. I do use use-package for loading and configuring my packages. This is what I tried so far (use-package origami) (use-package python :ensure ...
user avatar
  • 499
2 votes
1 answer
37 views

Strange autoindentation in org mode source blocks

I try to use org-mode as a replacement for jupyter notebook, and I was faced with a problem: when I edit a python src block, newlines don't indent properly, so I have to press space 4 times after ...
user avatar
0 votes
1 answer
36 views

How to hide a password in an org mode source block?

For educational purposes I'm using org-mode to explain some python by exporting to html and the :exports both header argument. pw="mypassword" def myFunction(apikey) print("foo&...
user avatar
  • 607
0 votes
0 answers
11 views

Elpy-shell-send-region-or-buffer fails on tabify

I'm using elpy for python development, and have elpy-shell-send-region-or-buffer bound to C-c C-c. However, when I execute this, it fails to send and I have this error in my logs: elpy-shell--string-...
user avatar
0 votes
0 answers
101 views

How to set up lsp + pyright to show all errors

I'm using recent nightly emacs in Linux/WSL2. I have lsp and lsp-ui, and am using pyright as the python LSP service. (pip install pyright). I like flycheck rather than flymake. I've been using lsp ...
user avatar
  • 406
1 vote
0 answers
67 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 ...
user avatar
0 votes
1 answer
30 views

Setup which-function-mode via use-package for python only

I was looking around in foreign but public init.el files and setup a which-function-mode that use the headline instead of the modeline for it's content. I couldn't find a use-package example for that ...
user avatar
  • 499
0 votes
0 answers
28 views

Python inferior process in emacs: input() function doesn't work when called with a prompt

In emacs, with an inferior python (v 3.9.7) running (called with M-x run-python): input() function works properly with no prompt when called with a prompt I get an error when entering the prompt in ...
user avatar
0 votes
0 answers
41 views

pylsp.plugins.flake8_lint - Error while running flake8 '/home/alper/venv/lib/python3.8/site-packages is in the MYPYPATH. Please remove it

In the *pylsp::stderr* buffer I keep seeing followin message: 2022-03-08 13:26:17,063 UTC - WARNING - pydocstyle.utils - Error code passed is not a prefix of any known errors: W0603 2022-03-08 13:26:...
user avatar
  • 1,112
0 votes
1 answer
37 views

python-docstring-fill does not align properly

I am using python-docstring-fill (function of https://github.com/glyph/python-docstring-mode) to wrap Python docstrings. I observe that it does not align based the Python-way. It should be as: "&...
user avatar
  • 1,112
0 votes
1 answer
43 views

How to load python layer after direnv?

In order to have lsp-pyright load after pipenv I need pyright to load after direnv. However, appending after: direnv results in an error[0] How can I have pyright starting the workspace after direnv? ...
user avatar
  • 607
1 vote
0 answers
83 views

How can I set up Emacs for use with Python with debugging and cross referencing?

I see a lot of links about lsp-mode, and have worked through the elpy setup https://elpy.readthedocs.io/en/latest/ide.html This is about getting emacs to do debugging in editor. The question I have is ...
user avatar
0 votes
0 answers
21 views

Elpy can't find py.test, even though it's available

I'm using elpy for python development. I run C-c C-t to run a single test, and I get: -*- mode: compilation; default-directory: "~/wrk/mydat/" -*- Compilation started at Fri Jan 28 17:50:10 ...
user avatar
0 votes
0 answers
56 views

Limited Python syntax highlighting when running Emacs via Terminal app on MacOS

On my Macbook, I get different syntax highlighting for Python depending on how I launch Emacs. If I launch via the MacOS app (installed via Homebrew) I get full syntax highlighting (first screenshot) ...
user avatar
3 votes
1 answer
47 views

Comint input and output text positioning

I'm using Emacs as a TCP client for a remote Python debugger I wrote. I can connect and interact with the server, but I'm not able to get the comint buffer used as the client to align input and output ...
user avatar
  • 3,835
0 votes
0 answers
16 views

Python autocomplete (company) inserts random mode string

When I have company-mode on I get the following useless autocomplete candidate repeatedly only in a python repl (inferior python started from python mode): # -*- mode:conf; -*- Why on earth is a mode ...
user avatar
  • 101
0 votes
0 answers
25 views

indent-region inconsistent with existing code that's indented more than python-indent-offset

Say I have an existing, simple block of code that uses an indent width of 4, as such def incDictValue(d, k): if not k in d: d[k] = 1 else: d[k] += 1 return and setup ...
user avatar
0 votes
0 answers
184 views

Python LSP Problems

I am having a strange problem. I have my init.el, ~/.emacs.d/lisp and a Python file tcvw.py synced between two computers running the exact same version of Emacs (27.1) and same OS (Debian Sid). In ...
user avatar
0 votes
1 answer
26 views

Completely removing all python-shell functionality

I'm running emacs 27.2 under Linux. I want to totally and completely remove all python-shell-* functions. I know how to unmap the python-shell-related keymappings, but I want to go further and remove ...
user avatar
  • 522
1 vote
1 answer
48 views

eshell: activate Python virtual environment from command prompt

I am aware of additional Lisp libraries that are able to activate a Python virtual environment without typing the following from an eshell command prompt: source /path/to/virtualenv/bin/activate. ...
user avatar
  • 17.6k
1 vote
0 answers
58 views

Themes and other options not loading from MELPA

While following a tutorial on editing python using Emacs (https://realpython.com/emacs-the-best-python-editor/) I've been unable to install better-defaults, line numbers and any themes or return to ...
user avatar
  • 11
0 votes
0 answers
15 views

How can I ignore new-line docstring skeleton inserted for Python using sphinx-doc.el

I am using sphinx-doc.el to insert docstring skeleton for Python functions. It always inserts additional newline add the end of each docstring skeletion. Would it be possible to prevent it? When I ...
user avatar
  • 1,112
0 votes
0 answers
14 views

How to have an elpy breakpoint in a different file

When running tests or scripts using elpy, I would like to set a breakpoint in a different file than the file that is the start of execution. However, from documentation, I see I can only set a ...
user avatar
2 votes
1 answer
131 views

How to activate a remote Python conda environment with Tramp / SSH?

I'm using Doom Emacs 27.2 on linux. I have (python +lsp +pyright +conda +cython) in my init file and (setq conda-anaconda-home "~/miniconda") in config.el. I can activate local conda env by ...
user avatar
  • 21
0 votes
1 answer
56 views

Error /bin/bash: line 1: nil: command not found

I have the following code to auto format python code using autopep8: (defcustom python-autopep8-path (executable-find "autopep8") "autopep8 executable path." :group 'python :...
user avatar
0 votes
1 answer
29 views

How to bind a terminal command to a key for python code autoformatting using autopep8

I'd like to autoformat my python code from the buffer that contains it with a key. I was looking at this tutorial. One can autoformat the code from the terminal with the command: autopep8 --in-place --...
user avatar
0 votes
0 answers
46 views

Elpy not working with python 3.10

It seems elpy doesn't work with python 3.10. For instance, see the issue here posted on the elpy repo in github. I had the same problem as that person mentions, and it seems many other people too when ...
user avatar
0 votes
0 answers
216 views

Setting elpy with python 3.10

I was trying to setup elpy with python 3.10 and get the following error: Elpy Configuration Emacs.............: 27.2 Elpy..............: Not found (Python), 1.35.0 (Emacs Lisp) Virtualenv........: ...
user avatar
4 votes
1 answer
220 views

How can I make python-mode correctly indent python's match statement?

Python 3.10 added a match statement. When I try and type one in emacs 27.2, it does not indent it correctly, presumably because it does not yet have support for it. How do I get python-mode to ...
user avatar
0 votes
0 answers
45 views

Auto-complete and syntax-fill modes for python and tcl

I am relatively new to emacs and I am looking for a few modes to make my coding in python and tcl easier on emacs. If you have done VHDL coding in emacs before, then you would have used VHDL shutter ...
user avatar
0 votes
1 answer
31 views

How do I change the python layer test command

I'm writing an app in python, which I will run in docker. Therefore I want to test it in docker as well. I'm working in spacemacs and want to use the tools available to test. With projectile this is ...
user avatar
  • 1
4 votes
1 answer
393 views

Is there indentation in org src blocks?

I'm going kinda crazy trying to understand what's going on here... Asked this question on the r/emacs subreddit so apologies if any of you are seeing this again. Do org blocks allow TAB indentation ...
user avatar
0 votes
1 answer
50 views

How to evaluate Python code blocks with pipenv instead of system environment?

I'm trying to use org-mode as an alternative to Jupyter. I'm able to evaluate code blocks with system environment by doing C-c C-c on blocks, but I don't know how to evaluate it through pipenv ...
user avatar
0 votes
0 answers
12 views

How to make python-mode follow indentation of first line for an entire block

I want python-mode to follow the indentation of the first line. I want to avoid having to issue C-c <, C-c >. If I have this block (source): def fib(n): # write Fibonacci series up to n &...
user avatar
0 votes
0 answers
51 views

lsp-mode get project error report

My problem is similar to what has been described here. I also would like to know whether there is a way to show ALL errors within a (projectile) project in a flycheck error buffer. I setup Emacs with ...
user avatar
  • 111
0 votes
1 answer
51 views

How can I jump beginning of the buffer under import section in python-mode

I am using beginning-of-buffer to the jump beginning of a buffer. Is it possible to achive same behavior but to the first line under the import or from` section in the Python mode. In this example I ...
user avatar
  • 1,112
1 vote
1 answer
50 views

Emacs 28 and python-mode the syntax font-lock-mode seems all off

I wanted to upgrade to emacs 28 to get f-strings support in python but the font-lock.... seem to be all messed up. Sometimes it works as in the past but sometimes it doesn't like why is ...
user avatar
  • 161
0 votes
1 answer
50 views

Company-anaconda works with root level Python installation but stops working when switching to conda environment with conda.el

I am on Arch Linux and use anaconda-mode with company-anaconda (here is a minimal init.el with which I can replicate the issue). I have Python installed both at root level from the primary package ...
user avatar
1 vote
1 answer
28 views

How are program arguments handled when a program/script is launched from Emacs?

I often find myself wondering how people handle program arguments when they are developing with Emacs. Let's say we have a Python script test.py and launching it requires supplying arguments, e.g. --...
user avatar
0 votes
0 answers
16 views

What's the correct way of setting python directory in mono-repo in spacemacs?

I've added the following to dotspacemacs-configuration-layers in my ~/.spacemacs config file: (python :variables python-backend 'anaconda python-test-runner 'pytest python-sort-imports-on-save t ...
user avatar
  • 215
1 vote
0 answers
34 views

Run current py-file

Maybe I am wrong to think that elpy is or should be able to do that. But can't I just run the current (means: open in current active buffer) py-file? I read about C-c C-c. But this just open a new ...
user avatar
  • 499
0 votes
1 answer
59 views

Org mode: How to get results from a code block with :session header?

First question: How does one catch the results out of the second code block below? #+begin_src python :session :results silent band = "ABBA" #+end_src #+begin_src python :session return ...
user avatar
1 vote
1 answer
76 views

How to toggle the *Python* buffer?

When working on python code in elpy, I like to have the python shell open. Often I don't want the *Python* buffer to be visible, especially with several buffers with Python code or long Python files ...
user avatar
  • 75

1
2 3 4 5
12