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

emacs opens py file as sh file

Emacs has opened a py file as a shell script. What went wrong and how to change?
0
votes
1answer
33 views

From one-line list to one element per line in python-mode

How do I turn a long one-line list, such as test_list = ['a0000000', 'b1111111', 'c2222222', 'd3333333', 'e4444444', 'f5555555', 'g6666666'] into a one element per line list: test_list = ['a0000000', ...
0
votes
2answers
47 views

Is there a way to show python generated plots in the python interpreter console?

I use emacs for most python programming, but really miss the inline plot feature combined with printed output in Spyder. See picture. I've been experimenting with various interpreter settings but ...
0
votes
1answer
42 views

Symbol's function definition is void: rx-let

Whenever I try to use elpy, or even just fontlock (with elpy disabled) in a python file, I get the error that rx-let is void. This is what I got from --debug-init: Debugger entered--Lisp error: (void-...
0
votes
0answers
23 views

Python indent region is wrong

Given the code: def main(args=None): if args is None: args = sys.argv[1:] load_data() Calling indent-region on the code (under python mode), the output would be: def main(args=None): ...
1
vote
0answers
20 views

Use conda environment in ansi-term

I would like to be able to use conda activate to switch between environments in ansi-term. I am running bash in ansi-term from Emacs 27.1 on MacOS Catalina. Currently, executing conda activate <...
0
votes
2answers
57 views

elpy flymake does not recognize local .pylintrc

I have the following in the project root for my .pylintrc: [FORMAT] # Maximum number of characters on a single line. max-line-length=1000 # String used as indentation unit. This is usually " ...
0
votes
1answer
46 views

How to turn off python-mypy in spacemacs flycheck-mode?

I'm using the latest Spacemacs with the Python layer. I'd like to turn off python-mypy in flycheck-mode, but the following in my ~/.spacemacs doesn't work: (defun dotspacemacs/user-config () (add-to-...
0
votes
0answers
14 views

Emacs python-mode language formatting does not reapply on buffer on newly typed text

When I open a .py file for the first time the formatting is perfect, colors match special words as expected in Python But when I type new text in the buffer, it inherits the color of the same ...
0
votes
1answer
42 views

How to run Python code and obtain its result in the minibuffer

I am using the following answer for How do you run Python code using Emacs. I was wondering instead of opening python shell using C-c C-z and running C-c C-c to get results; => Can only the output ...
3
votes
1answer
57 views

Can we do `C-c >` and `>` and `>` to continue indentation

I am using following answer to handle indentations Emacs bulk indent for Python C-c > or C-c C-l shifts the region 4 spaces to the right C-c < or C-c C-r shifts the region 4 spaces to the left ...
0
votes
1answer
21 views

How to modify a file you're debugging with realgud

I understand mechanically from here: debugging: how to optimize a RealGUD workflow How to edit code in the source window using realgud? I can use C-x C-q to disable read-only mode on the python file ...
1
vote
2answers
37 views

Why is the matplotlib plot produced by executing `org-babel-execute-src-block` contain errors?

The context Consider the following Emacs configuration $ cat ~/.emacs.d/init.el (org-babel-do-load-languages 'org-babel-load-languages '((python . t))) $ and the ...
0
votes
3answers
82 views

elpy (and evil-mode) do not react on TAB

This is my elpy-config 1Elpy Configuration 2 ...
1
vote
1answer
50 views

Confused regarding .dir-locals.el and projectile

I have a python project, it has tests and I can execute them from the command line. I just read about .dir-locals.el in the projectile documentation and I want to execute tests from inside emacs using ...
0
votes
0answers
18 views

Searching for functions

i have the problem, that lsp cant find my functions in python, because they are in a module, which is passed as parameter. What is a another good way to find the use of a specific function?
2
votes
1answer
90 views

Call Python from YaSnippet and insert result

I'm trying to build a comparable functionality as described here: https://castel.dev/post/lecture-notes-1/#sympy-and-mathematica Basically, he's using something comparable to yasnippet to send a ...
1
vote
2answers
83 views

how can I run conda in emacs shell?

I've been using Python command 'conda' in the terminal on my Mac. But when I run a command like 'conda activate ...' in Emacs's shell (M-x shell), it gives me this objection: CommandNotFoundError: ...
1
vote
2answers
51 views

Why is my Imenu not showing function and class definitions?

I feel like something is wrong with my Imenu setup, because here is what it shows on a simple Python script: It seems to show some variable definitions, but doesn't have separate entries for the ...
1
vote
0answers
21 views

How to replace sections of non-org files from within org-mode?

I am trying to write some notes on django with the help of org babel. Is there a way to replace a block in a file(which was not tangled with org) after I eval a certain src block? Here's what I mean: ...
0
votes
0answers
29 views

Automatically set `fill-column' based on flake8 setup

How can I automatically set fill-column based on flake8 configuration for python-mode buffers, specifically the max-line-length value in .flake8? Solutions that employs existing extensions are welcome....
0
votes
0answers
19 views

flycheck, elpy and re-displaying corrected python code

I've had Flycheck installed for some time, using flake8. This has worked for some time. When I had errors in a *.py program, they were indicated with markers by flycheck, and after correcting them, ...
0
votes
0answers
35 views

Python C-c C-c closes all other buffers

I am working with some python code and using C-c C-c to run one specific buffer while other python source files are open. As soon as it is launched, the other buffers are closed. This is highly ...
0
votes
0answers
34 views

Org Babel is returning the results of a cached file instead of the output of any org-babel blocks

NOTE: After restarting the python session and deleting all of the cache files about five separate times, everything started working as expected and I can't replicate the problem. I would still be ...
0
votes
1answer
92 views

How to set python indent offset to 2 spaces in elpy emacs?

I use elpy package for Python 3 in Emacs. It uses yapf to format a Python buffer. I have tried about everything, setting tab-width to 2 and setting python-indent-offset to 2 but nothing makes it so ...
0
votes
0answers
28 views

Python interpreter buffer stops working after a while

I am writing some python code and even when I run my code and the interpreter shows that the code is being run (by putting the code in there in blue), it doesn't show a result. It isn't even showing ...
2
votes
0answers
44 views

Unexpected indentation in python chunks

Already one year ago, I described a problem on github with polymode and unexpected indents. Since there was no answer there so far and the problem is really annoying, I ask here for ideas for a ...
0
votes
1answer
43 views

Setting Spacemacs default conda environment

This question answers where spacemacs looks for conda environments and how to change them with major-mode pyvenv-workon. There's one environment that I use for 90% of what I do. Can I set a default ...
0
votes
0answers
30 views

How many Python REPL's are there for emacs and their relative merits?

How many Python REPL's are there for Emacs and their relative merits? What OS have you tested them on? How long have you been using them? What version combos of python/emacs/ repl integrating software ...
0
votes
1answer
37 views

Configure gud to invoke python3 debugger instead of python debugger

When I issue the Emacs command M-x pdb it invokes Python’s pdb as python -m pdb foo.py. I want to instead invoke python3 -m pdb foo.py -- how do I set this up?
0
votes
1answer
27 views

Apply Python formatting rules to files not ending in .py

I need to edit a few .pyt files, which are python code but specific to ESRI ArcGIS software. Is there a variable that lists the file ending that python formatting is applied to that I could add .pyt ...
0
votes
0answers
75 views

Blacken installed but is giving the error that is isn't installed

I am running Emasc 26.2 on Windows 10 and have installed black via pip and installed blacken via melpa but when I enable blacken-mode it doesn't change any of the formatting even when I intentionally ...
0
votes
0answers
20 views

Emacs PNG as a text showing freezes

I am trying to see image as a text but when I compile this program in Emacs it freezes. Is the problem in Emacs when showing images as text? My Python code is right below. import requests as req ...
2
votes
1answer
33 views

Include lines in tangled source code but not in executed code block

The title might be slightly confusing. What I mean is this. Let's say I have a code block which has some error checking code. If there is an error, the (tangled) program should not continue past that ...
0
votes
0answers
92 views

Flycheck Trouble with Tramp and Python: “no module named /ssh:…/home/ubuntu/test.py”

Hi and thank You for helping! Overview I run a Linux Container (Guest) on my Machine (Host). On this guest I installed python3. Too, there I have a file "test.py". I edit this file via Emacs ...
0
votes
1answer
143 views

How can I start IPython from emacs

I deleted my old Python installation, so the only Python installation remaining is the one inside Anaconda. when I start Spyder I get: Python 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit ...
2
votes
0answers
32 views

How to move by defun without moving up a level?

I am attempting to navigate methods in a file. Typically these are javascript or python files, which have a classes at the "top level", which in turn have methods nested within those ...
2
votes
0answers
141 views

Automatically activating python virtual environments with pyvenv

I am using pyvenv with doom and am trying to have my python virtual environments automatically loaded when I enter a certain project. I saw this relevant issue on pyvenv and have added the following ...
0
votes
0answers
19 views

python: flake8 ignore __main__ scope in function's scope

I am getting following warning message for the following code: F821 undefined name 'variable'. // variable becomes color red. #!/usr/bin/env python3 def doo(): print(variable) # <= F821 ...
0
votes
0answers
23 views

Python automatically add import statement

Is there a way to automatically add imports to python code within emacs? def f(x: str) -> List[str]: I want to be able to have my guess over "List" press a key binding and magically add ...
1
vote
1answer
82 views

How do I make emacs indent relative to the beginning of the previous line?

Here's how emacs indents e.g. Python code: a = myfun(b, c) I'd like it to be this way: a = myfun(b, c) Reasoning? If I later replace myfun with myfunction, in the first case it becomes:...
0
votes
1answer
92 views

Pandas data frame as table

I'm enjoying learning org-babel to write literate documents and am trying to include summary tables produced by Pandas describe(). I found an old thread with some answers but none of the provided ...
0
votes
0answers
81 views

Python : name '__file__' is not defined

So as you can see, in my terminal, I was able to execute the file without error, but once I tried from the python shell, whether in the terminal or the one integrated in Emacs, there is an error, it ...
0
votes
0answers
41 views

Unable to change emacs python indent

My Emacs's python-indent-offset is fixed at 2, even though I have the below code in my init.el to set it to 4. I used C-h v to describe the variable, it says its value is 2 and default is 4. I removed ...
0
votes
0answers
15 views

virtualenv selection menu shows only the first few virtualenvs

I have a number of virtualenvs, currently 40, but when I try to select one via the drop-down menu in emacs, it shows only the first 30 or so. Is there a way to get a scrollbar attached to that menu, ...
0
votes
0answers
58 views

How to use exuberant ctags with python?

I followed instructions here: https://github.com/leoliu/ggtags I've enabled the following: (add-hook 'c-mode-common-hook (lambda () (when (derived-mode-p 'c-mode 'c++-mode '...
1
vote
0answers
24 views

How could I see the output of my Python code in the echo area?

When I press C-c C-c(python-shell-send-buffer), I get output shown below. Afterwards when I do the same operation (C-c C-c) I always see Sent: #!/usr/bin/env python3... in the echo area. I just want ...
0
votes
0answers
22 views

Why Jupyter console sometimes decide to output sometimes don't?

Problem I don't know why my Jupyter console sometimes doesn't output anything. An example is this: Notice that only the first line gets its output. I use C-enter to execute each line. Line 2, 3, 4, ...
0
votes
0answers
52 views

Ipython console on emacs like Spyder IDE

I am use Python sympy on IDE Spyder and the equations are shown on console, but in Emacs the equations are shown in another windows with ImageMagick. I want configure my Emacs like Spyder the show ...
0
votes
1answer
186 views

Problem with Flycheck and Python

I think that this is a newbie question, but here it goes: I have installed Flycheck just as in the official page. Therefore, in my .emacs file I added the following lines (after installing): (package-...

1
2 3 4 5
10