Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
31 views

does one has to explicity enable python-mode etc. to work with python files?

Sometimes I see people talking about enabling python-mode and so on. Is that only necessary for older emacs versions? I thought, the respective mode is enabled automatically when opening a ...
0
votes
0answers
32 views

strange minor modes and how to diminish them

I am working in a python file and thought I have diminished all modes accordingly, also yapfify. However, that does not seem to be the case as one can see in the screenshot. What are those cryptic ...
0
votes
1answer
21 views

python.el: auto save buffer before python-shell-send-buffer

Can python.el be set up in a way that it will automatically save the current buffer when python-shell-send-buffer is called (e.g. by C-c C-c)?
0
votes
0answers
27 views

Deleting temporary files left over from inferior-python-mode

I am using emacs on a server so files in /tmp are not automatically cleared down. Every time inferior-python-mode runs, it leaves files in /tmp (e.g. /tmp/py15458epk). I'm looking for a more elegant ...
0
votes
1answer
34 views

Autoinsert a python skeleton

I start my python files (.py) with #!/usr/bin/env python3 and sometimes if __name__ == '__main__': somefunc() having done it some hundreds of time manually I decided to automate it in Emacs. (...
1
vote
0answers
24 views

Docking a matplotlib window-manager window to an Emacs window

Short version: I want a way to "dock" a matplotlib window-manager window into an Emacs window (similar to the image below), while still keeping the functionality (e.g. zooming) offered by matplotlib. ...
0
votes
0answers
17 views

Ruby mode and/or snippets for jumping around statements

Is there currently a mode for the following examples: jumping to the end or beginning of a function the cursor is currently in. jumping around an if statement. ie from inside to the else, end and if ...
0
votes
0answers
82 views

`org-mode` Python source and results output

I was wondering if it is possible to export command outputs right after the commands in the org-mode. So instead of: #+BEGIN_SRC python :results output :exports results print(1) print('a') #+END_SRC ...
2
votes
0answers
57 views

Executing buffer twice in Python 3

I set up an environment to write Python 3 Code in my emacs (25.2.2) using python-mode and Elpy on Ubuntu 18.04. Strangely every time I use Python --> Send --> Execute Buffer the program is executed ...
1
vote
1answer
75 views

Can’t guess python-indent-offset - delete warning when local file variable

I have this comment that I write in my python file # -*- Mode: Python; tab-width: 8; indent-tabs-mode: nil; python-indent-offset: 2 -*- # vim:set et sts=4 ts=4 tw=80: But when I load a python file, ...
0
votes
1answer
85 views

Autocomplete after dot in python

I haven't used emacs before, but would like to learn how to use it properly for Python development. From the past IDEs I have used I enjoyed the feature to obtain information on possible objects ...
0
votes
0answers
32 views

elpy autocomplete stops working unexpectedly

I've configure emacs to write python code and I love it!:). It works very well but after some situations that I cannot understand the autocomplete stops working on all buffers. If I restart emacs it ...
0
votes
0answers
37 views

Cannot change flycheck-python-pylint-executable

I have been trying to make flycheck use python 3 syntax similar to this question and ended up having more fundamental questions. I open a python file and flycheck correctly works, using the python 2 ...
0
votes
0answers
19 views

run-python and interactively choose working directory

When starting an R process using ESS (M-x R) you are interactively asked for a working directory. To replicate this behaviour for python I have been opening up some random file in the directory I ...
0
votes
0answers
15 views

How can I use bandit with flycheck in Spacemacs?

How can I integrate bandit with flycheck in Spacemacs? I know there is flycheck-pycheckers. But I would prefer to have a separate integration for bandit only.
1
vote
1answer
143 views

Activating a conda environment in emacs

I've got code that needs python 2.7 (and other environments) C:\Users\Me>conda info -e # conda environments: # base * C:\Program Files\Anaconda3 python2 C:\...
1
vote
2answers
72 views

Babel + Python function definition with for loop causes IndentationError

I am using orgmode and Babel to run Python source code blocks. I noticed that if I define a function that returns a value, and if this function has a for loop inside it, then evaluating it with Babel ...
0
votes
1answer
41 views

python-shell-completion-complete-or-indent no mathes in ipython

import pandas as pd pd. # press tab, there are completions df = pd.DataFrame() df. # press tab, No Matches Same configuration worked on my local mac but not on linux server. If I use python ...
0
votes
1answer
35 views

Anaconda Mode only complete module variables, get No Matches for assigned variables on linux server accessed via ssh

Description Anaconda Mode only complete module variables, get No Matches for assigned variables on linux server accessed via ssh Reproduction guide Observed behaviour: - Start Emacs execute import ...
1
vote
0answers
57 views

Jedi doesn't work properly with PyQt5

I have auto-complete and jedi installed and everything works just fine except autocompletion in PyQt5. When i try to subclass for example QWidget and in the __init__ method I type self and then press ...
1
vote
1answer
35 views

Is there an integration between projectile and python-mode that allows for one python interpreter buffer per projectile project?

I use projectile with python (and anaconda mode) to work in emacs. When starting an ipython interpreter buffer, the first such session works fine. However, attempting to start a second session, for ...
0
votes
1answer
76 views

Changes in python mode Emacs 24 → 26

Certain key combos seem to have changed behaviour from emacs 24 to emacs 26 in python mode (python.el). Notably: Emacs 24: (no python shell open yet) C-c C-c: Run python: ... ; Dedicated process?; ...
2
votes
1answer
42 views

prevent EMACS LaTeX mode from indenting pycode environment?

I'm using pythontex to allow me to embed Python code in LaTeX files. (It's really great, BTW.) I edit my LaTeX with EMACS. Unfortunately, EMACS thinks that any environment should be indented, and if I ...
2
votes
0answers
67 views

Emacs/realgud/Python: How to display variables at each step?

Using emacs and realgud one can have a separate buffer that automatically shows where the program is currently stopped (by displaying that line of source code). Is there an easy way to get realgud to ...
0
votes
0answers
78 views

Display two vertical rules, at columns 79 and 87

Python code now often is limited either to 80 columns, or to 88 columns. fci-mode allows drawing a vertical rule at a single column, but not two. I'd like to do something very similar in appearance ...
1
vote
1answer
24 views

Elpy - Close Window when invoking elpy-shell-kill

Elpy helps a great deal, when editing Python-Code. For example it let's you run the current file with C-c C-c in a new Window with a REPL. When i'm done with this, i can hit C-c C-k (elpy-shell-kill) ...
3
votes
2answers
109 views

function to convert python dict arg to kwargs?

I would like to be able to start with code like this: def foo(a, b, {"c": 1, 'd': 2, "e": 3}): then execute some emacs function with my cursor anywhere between the {} characters, and rewrite the ...
0
votes
0answers
208 views

Enhance python lsp-mode with elpy functions and keybindings

I've been using Elpy for a long time and have grown used to many of the default keybindings. I recently decided to give lsp-mode a go to see how it compares. I set it up following this blog and made ...
1
vote
1answer
63 views

Problem debugging in `gud-mode' (M-x `gdb' with `many-windows' enabled)

I'm debugging a large codebase (written in C++). Everything works perfectly if I run gdb from a regular terminal as follows: $ gdb <program-name> Reading symbols from <program-name>......
2
votes
1answer
385 views

Org-babel Python with :session

I don't know what happened with org-babel and Python recently. My intuition and my experience with preparing lectures last year was that the :session option would cause Org Mode to capture all the ...
1
vote
0answers
41 views

Flycheck Python introspection into modules?

I have flycheck working seemingly as advertised with Python on Emacs 25.2.1. The configuration check shows all dependencies are satisfied and enabled. It does handle introspection within the same ...
1
vote
2answers
175 views

Kill inferior python in python.el mode

At the moment I am killing the Python interpreter with C-d each time I want to quit Python interpreter. What is the name of the function to kill the Python interpreter in Python mode (the one which ...
1
vote
0answers
14 views

Flycheck error buffer empty for python files in the {package-name}/bin/ directory

I have this odd problem when I run flycheck on the python files inside the {package-name}/bin directory of my git repository. When I attempt to run flycheck on these files, the buffer with the ...
0
votes
0answers
156 views

(wrong-type-argument number-or-marker-p nil) when calling run-python

When I call run-python from the package python.el Emacs displays me the following error: error in process filter: Wrong type argument: number-or-marker-p, nil To investigate further I called toggle-...
2
votes
0answers
48 views

C-c ' for editing all code blocks (to handle imports and variables)?

The Org manual says: C-c ' for editing the current code block. It opens a new major-mode edit buffer containing the body of the ‘src’ code block, ready for any edits. This feature is sweet. ...
1
vote
1answer
86 views

Open a file in read-only preprocessed mode

I often create files with a special extension, e.g. pkl (python pickle), and would like to display these in a read-only buffer after processing them with some external command. E.g. in the case of ...
1
vote
2answers
396 views

emacs and anaconda ipython

I'm trying to get Emacs to start ipython from Anaconda. I have two systems which are not identical so figured setting symbolic links in ~/bin/ipython as I have ~/bin/ pre-pended to my $PATH would do ...
2
votes
1answer
65 views

ModuleNotFound for absolute imports in Emac's Python Repl

For some reason, emacs does not seem capable of evaluating absolute imports for any python project I run. Here is my project layout: ├── loxy │   ├── errors.py │   ├── __init__.py │   ├── loxy.py │   ...
1
vote
0answers
81 views

Org Mode Python block evaluation cannot print result in the shell session

I have a python source block in org mode as below #+BEGIN_SRC python :session print('hello world') #+END_SRC and I have a Python shell already run, so when i press C-c C-c, the code gets ...
0
votes
1answer
1k views

Emacs Company-Jedi Python3 auto completion

I am trying to setup company-jedi to autocomplete for python3. The autocomplete is working for standard python3 modules; however, it is not working for packages I installed using pip3, in this case ...
4
votes
2answers
74 views

How to get rid of flickers in python shell?

In a fresh emacs session, each time I hit enter in inferior-python-mode, the window flickers. This does not happen in shell-mode. One can see the cursor goes to the middle of current window when ...
0
votes
0answers
132 views

Syntax highlighting not working in Emacs (in Python mode)

When I Python-mode I have noticed that occasionally my syntax highlighting is not working. I have noticed this when using the Cyberpunk theme as well as the Tango-Dark theme. Closing and reopening ...
1
vote
0answers
25 views

fixing python-mode automatic line-breaks in the output?

I'm using emacs python mode to evaluate python (3.6) code and expressions. The mode (or emacs) seems to automatically break output lines at a certain length, even though my screen is wide enough to ...
0
votes
1answer
113 views

Interpreter discrepancy in org-babel-python and python-mode

(Emacs version 26.1, Org version 9.1.9) I have tried numerous solutions to get working in org-mode source blocks. This solution works to change python-mode to utilize the Python3 interpreter, which I ...
0
votes
0answers
41 views

How to convert a region into a Python function?

I'm using emacs with evil and anaconda mode for Python. Sometimes I'd like to convert a region or a block of selected lines into a def (or for/while loop, or class). Is there a way to do this ...
1
vote
1answer
112 views

Using xonsh as python shell

I'm trying to use xonsh as my python interpreter in Emacs (the one invoked by run-python). I tried to do this by setting python-shell-interpreter to "xonsh". This works, but there are two issues: The ...
0
votes
0answers
57 views

Eldoc appears briefly and then disappears

When I move into the parameter list of a Python function, eldoc briefly shows the parameter help in the minibuffer but disappears abruptly. How can I find what is causing this issue?
0
votes
1answer
213 views

Using tab as indentation in anaconda-mode with spacemacs

I recently installed spacemacs with the python mode and would like to change the default indentation to be TAB instead of four spaces. What I did is I added (setq-default indent-tabs-mode t tab-width ...
1
vote
0answers
59 views

How can I execute a python script on a given region of my buffer?

I have a .tex source and a python script called comments.py. This script reads my .tex source as input, does some operations on it and write a .com file as output. Then I have to reneame .com as .tex ...
1
vote
1answer
30 views

Can I return multi value in emacs org src code?

As follow code,can I get a list for other code block? #+name: test #+BEGIN_SRC python -n :exports both for i in range(5): return i #+END_SRC #+RESULTS: test : 0