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
2 views

python linting not working with eglot

System: Mac OS 12.5 Emacs 28.1 from homebrew Python 3.9.13 using a virtual env python-lsp-server For some reason my linting, with error highlighting is not working with Python using eglot. In the ...
user avatar
  • 345
0 votes
1 answer
21 views

How to remove the visual vertical bars for Python files?

I am using Emacs 27.2 on a Mac OS with Steve Purcell's configuration. I have got some visual vertical bars for Python files. How can they be removed?
user avatar
  • 163
1 vote
0 answers
14 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 ...
user avatar
  • 111
1 vote
2 answers
152 views

Leading * breaks code

I don't know if the presence of a leading * was meant to be in the code or if it's just a typo, but still I didn't expect it would break the code as if interpreted as a headline. Has dis been ...
user avatar
  • 535
0 votes
1 answer
37 views

Python-mode font-lock: change the color of the equals sign in function keyword assignments

In Python, keyword arguments passed to functions can take the form of "keyword"="value", such as in this example: some_function(somearg="foo", someotherarg=True) I'm ...
user avatar
  • 143
0 votes
1 answer
29 views

With LSP, how to get an "input()" in python that works when entering data using the keyboard

Here is a minimal example: I created and activate a virtual environment: ~/BacSable/bac2 $ mkvirtualenv minimal_env created virtual environment CPython3.10.5.final.0-64 in 651ms creator ...
user avatar
0 votes
1 answer
33 views

elpy installed in the virtual environment, but elpy-config says Not Found

I am running emacs-28.1 and starting of with elpy. My current python development section is as follows: (use-package elpy :ensure t :defer t :init (setq elpy-rpc-python-command "python3&...
user avatar
  • 105
2 votes
0 answers
22 views

Org mode babel hangs with python C-c C-c

When I C-c C-c in a Python code block in Org mode: #+BEGIN_SRC python :results value :session a = 4 a + 13 #+END_SRC It hangs with a message: Warning (python): Your ‘python-shell-interpreter’ ...
user avatar
  • 121
1 vote
1 answer
33 views

macos org-babel python with session output give __PYTHON_EL_eval

#+begin_src python :session :results output print("yes") #+end_src With org-babel-execute-src-block command, the result is: #+RESULTS: : __PYTHON_EL_eval("try:\n with open('/var/...
user avatar
0 votes
1 answer
49 views

How can I add the current directory to `PYTHONPATH` automatically?

I use elpy and I am not able to use relative paths to access files because the PYTHONPATH doesn't include the directory I'm in by default. I may have set it up wrong in elpy-config. Here are my paths ...
user avatar
1 vote
0 answers
26 views

Some errors when customizing run-python

I want to make a complement to run-python in python-mode. Here is my snippet: (defun dpy-run-python () (interactive) (when (python-shell-get-process) (delete-process (python-shell-get-...
user avatar
  • 11
2 votes
1 answer
43 views

Trouble setting up dap for python in Spacemacs

I've been trying to get dap working with python in Spacemacs for a week. I'm trying to start using Spacemacs as my main Python IDE, I should mention I'm new to emacs and spacemacs, I could be missing ...
user avatar
  • 141
1 vote
1 answer
19 views

Python Eldoc fails when editing a remote file with a local shell open

Problem: Eldoc constantly spews FileNotFoundErrors into the minibuffer when editing a remote python file if you have a local python shell open. To Recreate: > emacs -Q M-x run-python open a file ...
user avatar
1 vote
2 answers
68 views

Symbol's function definition is void: python-font-lock-assignment-matcher

My emacs won't start properly any more. The basic, unmodified interface is opened with the following error: Warning (initialization): An error occurred while loading ‘/home/qohelet/.emacs’: Symbol's ...
user avatar
  • 163
1 vote
0 answers
45 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 ...
user avatar
0 votes
1 answer
91 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
48 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
94 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
  • 163
0 votes
1 answer
23 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
  • 629
0 votes
0 answers
43 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
  • 263
0 votes
0 answers
24 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
2 answers
83 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
61 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
  • 569
2 votes
1 answer
49 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
56 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
  • 629
0 votes
0 answers
13 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
396 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
113 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
38 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
  • 569
0 votes
0 answers
31 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
56 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,076
0 votes
1 answer
54 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,076
0 votes
1 answer
69 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
  • 629
1 vote
0 answers
87 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
29 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
1 answer
86 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
60 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,915
0 votes
0 answers
20 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
27 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
235 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
30 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
83 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.8k
1 vote
0 answers
64 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
19 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,076
0 votes
0 answers
18 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
3 votes
1 answer
208 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
  • 31
0 votes
1 answer
79 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
39 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
56 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
316 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

1
2 3 4 5
12