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
0answers
15 views

How to run pytest in org mode babel?

#+begin_src python :results output import pytest def test_func(): assert 1 == 1 pytest.main() #+end Should pass, though the test isn't even collected ============================= test ...
0
votes
1answer
16 views

Yasnippet-snippets indention not correct for Python functions

Yasnippet-snippets contains a snippet for Python mode to create a function with a docstring. The indention is not correct when I use it, I think it maybe has to do with some Spacemacs settings, but I ...
0
votes
0answers
23 views

How can I access the python documentation for the thing at cursor?

with open("foo.txt", mode="create") as f: print(file, text[0:300], file=f) ValueError: invalid mode: 'create' Now pointint the cursor on =open=, followed by hitting , h offers:...
0
votes
0answers
10 views

How do I upgrade the version of python that jedi uses?

I've upgraded the version of python on my computer, but emacs-jedi is still using the old one. I presume this because we are still using the old version of python used in ~/.emacs.d/.python-...
0
votes
0answers
10 views

Emacs python-shell: edit local, execute on server

I am editing a python file on my local machine and executing it on a server. I would like to use python-shell-send-region, python-shell-send-line, python-shell-send-buffer, etc but these functions use ...
0
votes
1answer
28 views

Emacs >27.1: How to highlight in different colors for variables inside `fstring` in python-mode

I am using python-mode which colors the parameters. When I concatinate strings the variable color is represented as different: On the other hand, if I use fstring, the variable is not represented as ...
0
votes
0answers
5 views

Spacemacs: Python auto-completion works on Linux but not MacOS

I just installed Spacemacs on both my Linux and MacOS machines, but for some reason python autocompletion is not working on the MacOS installation. On Linux, I enabled the python layer and auto-...
0
votes
0answers
9 views

anaconda-mode completion not working for python3 modules from pip3 and non-standard python3 modules from Debian repos

Using Spacemacs 0.300.0 develop on Debian 10.9 (stable). My python setup in .spacemacs: (python :variables python-backend 'anaconda) I also have the following in my user-config: (setq python-shell-...
1
vote
0answers
20 views

How to define global keybinding for `C-c >` and `C-c <` using defhydra

I am trying to apply following solutions's keybinding to overwrite all mode's keybindings for C-c > and C-c <. From the answer for Can we do C-c > and > and > to continue indentation: (...
0
votes
0answers
13 views

Defining a poly-mode for python docstrings

I was trying to define a polymode so python docstrings have markdown-mode in them. My code for now is: (use-package polymode :ensure t :config (define-hostmode poly-python-hostmode :...
0
votes
0answers
14 views

Auto-saving after lsp refactor

When I use lsp-rename function, the edited files are not saved automatically and I have to manually save them. Is this an expected behavior and, is it possible to change this? (I use emacs 27.2, with ...
0
votes
0answers
27 views

use-package keybind only works with eval-buffer

The following init.el keybind doesn't work after starting emacs, only when I eval-buffer init.el (otherwise C-c C-d just goes to its default bind in python-mode): (use-package python-mode :ensure ...
0
votes
1answer
267 views

How to set up pyrightconfig in lsp-pyright?

I am using lsp-pyright[1] module in doom Emacs for Python major mode. Local imports from my project are not recognized by lsp server. I have created a pyrightconfig.json file in root directory of my ...
0
votes
0answers
43 views

How to apply `yasnippets` only for keywords at the beginning of the line? [duplicate]

I am using Python but some pre-defineted snippets. I was wondering is it possible to apply them if the keyword is the first word. if and [TAB] converted into if cond:. I want this behaviour if the ...
1
vote
0answers
65 views

Python indent alignment for the inner if condition

I am using tab for indent alignment, I believe its a built-in emacs behavior in python-mode. In most cases if cursor is at the beginning of the line and when I press TAB, first** cursor jumps to first ...
0
votes
1answer
159 views

Python formatting not working on Doom Emacs

I activated the formatting on save in the init.el file uncommenting the following line (format +onsave) ; automated prettiness But when I save a Python file, I get the following error message: Error ...
0
votes
1answer
63 views

Get process id (pid) for running python (jupyter-kernel)

I've started a jupyter kernel form emacs-jupyter. I'd like to get the process id for the python process associated with the buffer so that I can attach a debugger to it. How can I do this in elisp?
0
votes
0answers
28 views

Assign a keybinding with “C-[” [duplicate]

I want to set shortcuts for the following functions: python-indent-shift-left and python-indent-shift-right. I can do the following and it works. (bind-keys :package python :map python-mode-map ...
0
votes
1answer
20 views

Running elpy-test on a file opened over ssh via tramp

I'm trying to run elpy's C-c C-t to do elpy-test on a python test_x.py file I have opened on a remote machine with TRAMP. Some parameters: There is a python virtual env in the (remote machine's) ...
0
votes
0answers
11 views

Can I send python code to an external terminal running ipython?

Is there any way I can select some code in emacs and send it directly to, say, an xterm instance running an ipython kernel?
3
votes
1answer
52 views

Org mode python code block with session does not return a result

I had been successfully using python code blocks with the :session header argument when I noticed that upon export no result was given. I then simplified my example to the following two: #+...
0
votes
0answers
33 views

ANSI colors are incorrectly displayed in Inferior Python mode REPL

ANSI escape color codes, e.g. "\u001b[31m", are incorrectly printed in the Python REPL, inferior python mode. They are correctly printed in VTerm, where they are displayed the same as when ...
0
votes
0answers
19 views

Avoid font lock in special strings

Consider the following python code: As you see the content of expr is font locked as string. How can I emacs make to format it as if expr=''' and ''' were gone: Other strings should be font locked ...
1
vote
0answers
39 views

How to install mspyls without internet?

I would like to install mspyls language server on my work machine that does not have access to an internet. I am able to transfer files over to the work machine via thumb drive. Is there a way for me ...
0
votes
1answer
18 views

How do I change the Python interpreter in Aquamacs 3.5 (based on GNU Emacs 25.3.50.1)?

I have been unable to get my Aquamacs 3.5 (built on Gnu Emacs 25.3.50.1) to run Python 3. I have put the following lines in both my Preferences.el (the Mac equivalent of .emacs) and within an ...
0
votes
1answer
33 views

Showing full (unabbreviated) Python output in Org Mode

The result of a certain Python (statsmodel module) code in org-mode is abbreviated: #+BEGIN_SRC python import pandas as pd import statsmodels.api as sm auto_df=pd.read_csv('Auto.csv', usecols= [...
0
votes
0answers
91 views

Why is Selenium / Chromedriver giving me errors in Emacs' Python shell?

If I launch a Python shell inside Emacs with run-python and try to open a Chromium window with Selenium, I am suddenly running in to the following error: Python 3.8.5 (default, Jan 27 2021, 15:41:15) ...
0
votes
0answers
19 views

Report wrong Elpy-Behaviour, but to whom and how?

I'm using emacs to write my python-code and lately I found some wrong behaviour of one of the auto-format-features: Given this wrong code: def doStuff(self, s_database): return ("ASDF" @...
0
votes
0answers
21 views

How to fontify keyword arguments in `python-mode`?

I'm coding in python and it seems like the python-mode doesn't color the keyword-arguments. Note that I'm not talking about general keywords but keyword-arguments. As an example, in the next picture, ...
4
votes
1answer
56 views

Annoying “error in process filter: Overlapping strings detected”

When editing python code with elpy, if I type a single or double quote while writing a new line of code (i.e. adding or changing a line in existing code), the UI freezes momentarily, make the bell ...
3
votes
2answers
67 views

Is it possible to suppress `Fill column set to 80 (was 80)` message in the echo area?

When I open a Python file I keep seeing Fill column set to 80 (was 80) message in the echo area. I know I have set it this limit , but I don't want to be keep reminded about it. Is it possible to ...
1
vote
0answers
120 views

`lsp` does not start on python-mode-hook

I am using lsp under Python.lsp does not start when a Python file is opened, I have to do M-x lsp for each file I open. Also when I switch from find-file to another file I have to do M-x lsp all over ...
0
votes
0answers
11 views

Ipython as run-python binary, no tab complete

I've been using the standard python repl in emacs for a while and decided to change to use ipython with all of it's autocompletions and other features. Unfortunately, if I try using ipython in multi-...
0
votes
1answer
33 views

Toggling off all settings in python and julia to get bare setup

since recently I am using LSP for python, tex and julia on macos with spacemacs develop. To some extend this is great, but it is something awefully slow using a gui... and it seems that it is not only ...
1
vote
1answer
19 views

How do I get org-mode to treat the output of a non-latex code block as latex?

(Emacs: v27.1, Org: v9.5, pdfTeX: v3.14159265-2.6-1.40.21) I am using the following Python code block to print LaTeX code: #+BEGIN_SRC python :session :exports both :results output :wrap math ... #+...
0
votes
1answer
104 views

How can I jump back after `rope-goto-definition`?

I am using rope-goto-definition to jump into a module's definition, link. But I cannot jump back to where I was. xref-pop-marker-stack says Marker stack is empty. Is it possible to jump back after ...
0
votes
1answer
62 views

How to open org-mode table as a pandas dataframe (with column names)?

I can't find how to open an org-mode table as a pandas dataframe. Here is my example: #+NAME:tbl | a | b | |---|---| | 1 | 2 | #+BEGIN_SRC python :var tbl=electro :results replace output :session ...
0
votes
1answer
40 views

Repeating characters in `python-mode.el` shell interaction

I experience strange behaviour when using python-mode. When sending characters to the shell using C-c C-e, the first string works well. After that, the characters start repeating, in a manner that is ...
0
votes
0answers
27 views

Can't reproduce my (spacemacs) config

Two PCs, same version of manjaro on both, same emacs version, same spacemacs version/branch, same config file. Problems with python mode and company: On my second PC, autocomplete doesn't work ...
0
votes
1answer
32 views

How to restart elpy if it is not launch?

I am working with python using Emacs 26.3. My goal is to jump to definition of the function and jump back, for that I am using https://github.com/jacktasia/dumb-jump, which runs elpy-goto-definition ...
0
votes
1answer
43 views

How to color specific keywords in python-mode?

My goal is to color specific keywords as function definition such as log in Python-mode to a spefic color or color of functions. Example, pattern for log("...."): coloring only log. from ...
6
votes
0answers
165 views

xref unsuccessful in python buffers: “no definition found”

The command xref-find-definitions is no longer working for me in Python buffers (with elpy-mode enabled. Its companions, such as xref-find-references, are also not working in Python buffers. ...
0
votes
1answer
33 views

How do I open an inferior Python process in a full window from the command line?

From the command line, I want to open an inferior Python process in a full window. I have tried: emacs --eval '(run-python)', but when Emacs opens, the *scratch* buffer is shown instead of the ...
0
votes
1answer
45 views

How to apply flycheck right after a new file is opened

I am using flycheck for for Python. I want flycheck to detect any errors right away when any Python file is opened. Currently it can detect if there is a modification and save operation is performed. ...
0
votes
0answers
56 views

How to remove <header-line>

I'm pretty much emacs noob. I've been tinkering in spacemacs for around a month now and got it set up pretty much how i like it. But since i updated it, header line that appears when i open a project ...
0
votes
0answers
103 views

mypy FileNotFoundError: [Errno 2] No such file or directory: '.mypy_cache/3.8/utils.data.json'

I keep having following warning message, even I have the recent version of python-mypy not sure why this warning message is generated; is there any way to fix this: Try installing a more recent ...
2
votes
0answers
41 views

See mypy type of what's under point

Is it possible to see mypy types in emacs? I would like a command that does something like show the type of what's under point (presumably getting that information from the mypy cache for speed?). ...
0
votes
1answer
41 views

How do I specify the window height of the Python interpreter?

Suppose I am editing a file in python-mode. If I start the Python interpreter using M-x run-python (or C-c C-p), the Python interpreter opens in a window (*Python*) in the bottom half of the frame. ...
0
votes
0answers
42 views

importmagic.el isn't respecting configuration style

I am following the instructions here for how to customize importmagic. I have the following in my init.el: (setq importmagic-configuration-style-alist '((multiline . backslash) ...
0
votes
0answers
88 views

importmagic for python

I have the following in my .emacs.d/init.el, along the lines of what is suggested here: (require 'importmagic) (add-hook 'python-mode-hook 'importmagic-mode) (define-key importmagic-mode-map (kbd &...

1
2 3 4 5
11