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

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 ...
0
votes
1answer
35 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 ...
1
vote
1answer
24 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. --...
0
votes
0answers
8 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 ...
0
votes
0answers
13 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 ...
0
votes
1answer
27 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 ...
1
vote
1answer
59 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 ...
0
votes
1answer
127 views

How to ignore specific flycheck warning messages for Python in lsp-mode?

My goal is to configure lsp in order to ignore warning messages for flycheck in Python version. When lsp is not in use, flycheck reads from my ~/.pylintrc file in order to ignore warning messsages. ...
0
votes
1answer
9 views

org-babel pass bibtex sample to python code block

Is it possible to pass a sample bibtex document into a python source code block to be evaluated? :PROPERTIES: :ID: d7154890-6d45-44c0-9b0c-9c0f6533c11e :header-args: :session bibtex :END: #+...
0
votes
0answers
18 views

Python in eshell on Windows 10

I'm using Emacs v27.2 on Windows 10 and I would like to run Python inside eshell mode. It works in shell mode, because this is the native OS shell and I have Miniforge3 installed and in my PATH ...
0
votes
0answers
19 views

Autocompletion broken after loading certain module

I'm using Emacs (GNU Emacs 26.1 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.22.30) of 2019-05-11) on CentOS 8 and want to use autocompletion when coding with python. Emacs.............: 26.1 ...
0
votes
0answers
38 views

I do not want a TAGS table, flaky elpy-goto-definition

I use elpy for python development, and the command M-., elpy-goto-defintion to follow a function to its definition in a python project is a life-saver. There isn't a TAGS table anywhere in my project, ...
0
votes
0answers
59 views

How to auto complete in python mode?

How can I auto-complete common python code e.g. for, while, def? For example after typing de The keyword appears, yet nothing happens hitting RET. In org mode I type e.g. ema, hit RET on emacs-lisp. ...
0
votes
0answers
22 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
25 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
1answer
50 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
11 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
13 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
29 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
10 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
35 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-...
2
votes
1answer
63 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
21 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 :...
1
vote
1answer
36 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
29 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
716 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
287 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
107 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
30 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
34 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
14 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
117 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
47 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
20 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
56 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
31 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
41 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
99 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
23 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
90 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
99 views

How do I suppress messages in the echo area (e.g. `Fill column set to 80 (was 80)`)?

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
163 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
13 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
39 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
134 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
74 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 ...

1
2 3 4 5
11