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

Running Anaconda Python within emacs on Windows

I have a Windows 10 machine, with the official GNU emacs Windows build, and Anaconda Python 3.7.3. I can't get Python to properly run within emacs. Whenever I start Python, I get the message: ...
0
votes
0answers
19 views

Spacemacs org-mode python session plotting problem

I have been using org-mode with R in Spacemacs for a while now with no issue. I'm moving my workflow from R to Python. Jupyter notebooks (EIN) works great, but I prefer org-mode: Normal (non-...
0
votes
0answers
16 views

Turn on Black-mode rather than fly-check mode

The emacs configuration I cloned, turn on Flycheck mode by default, When working on python codes, how could turn on Black-mode instead of Flycheck mode globally?
0
votes
0answers
27 views

Unittest in org source code

Upon working in org doc with source code, I want to do unittest whithin #+BEGIN_SRC python :session my :export none :results output import unittest def square(n): return n ** 2 class ...
0
votes
0answers
10 views

spacemacs python autocompletion and g d (go to definition) don't work if file is in subdirectory

Within a single file autocompletion and g d (go to definition) work as expected. If I import something from another file under the same directory - also works fine The problem is when I import file ...
0
votes
0answers
31 views

wrong cwd in python mode

When i do C-c C-c on a python module, it leads to *Python* buffer with Inferior Python : run Shell-Compile mode. Suppose the correct cwd is /x/y/z/ The problem is when I print os.getcwd(), i get ...
0
votes
1answer
25 views

Updating pyenv when switching to a Python buffer

I use pyenv to maintain my python versions and virtualenvs. I really like the way you can create a local .python-version for each project, pointing to the version I need. I use pyenv-mode which allows ...
0
votes
1answer
42 views

Python Documentation String Indent In Auto-Fill Mode (Emacs 26.2)

I've noticed a peculiar behavior when using auto-fill-mode editing Python code. For example if I start typing the following (fill-column is set to 79): def some_function(keyword_argument0, ...
2
votes
1answer
29 views

How to use python listdir in org babel?

While the command below returns filenames in the commandline, I somehow can't get the same result using org-babel: #+BEGIN_SRC python :results output import os os.listdir(path='.') #+END_SRC #+...
0
votes
0answers
29 views

Get autocomplete information from inferior python process

When using pandas, I can get dot completion to work for column names in the inferior python process but not in my file. Is there any way to link the two? I am using elpy for my python work. This is ...
0
votes
0answers
51 views

Spacemacs - python mode

I have some problems with my spacemacs configuration. For instance, it's supposed to be globally set up with emacs editing mode and the line numbers as well dotspacemacs-editing-style 'emacs ...
0
votes
1answer
49 views

set key for 'comment-or-uncomment-region in python-mode

i want a shortcut for the nice little function comment-or-uncomment-region. The thing is, it works fine for me in every mode using M-x comment-or-uncomment-region. And espacially it works differently (...
0
votes
1answer
21 views

Python, How to find the right indent level when the openning of desired indent level is not visible in a screen?

say you have for user_id, group in df.sort_values( ['user_id', 'timestamp'], ascending=[True, False] ).groupby('user_id'): group = group.reset_index() positive = ...
1
vote
0answers
76 views

Elpy auto-complete gives incomplete suggestions

I am trying to use Elpy for Emacs to write Python programs. The auto-complete feature suggests all attributes of PyQt5 classes, but suggests only a subset of the attributes of instances of these ...
1
vote
1answer
91 views

How to gnuplot a referred evaluated table in org-babel?

Hitting ctrl-c ctrl-c on the gnuplot code block returns: org-babel-ref-resolve: Reference ‘foo’ not found in this buffer #+srcname: foo #+begin_src python :results output raw :exports code import ...
1
vote
0answers
42 views

Associate a buffer with a process

I am using Python with elpy. I am trying to use a Python shell opened on the remote computer using a shell buffer. I can cheat elpy by renaming the shell buffer with Python running in it to *Python*. ...
0
votes
2answers
70 views

pdb within eshell up/down keys dont work

I am running python3 in eshell. When I use import pdb; pdb.set_trace() in my code, pdb opens within eshell. Everything works in pdb but the up/down keys don't work for running the previous command. ...
3
votes
1answer
94 views

How do I disable python-help

I just upgraded to Emacs 26.1 on Linux (Ubuntu 18.04, but emacs26 from the kelleyk repo). python-mode is now bringing up a *Python-Help* window whenever the cursor in on a symbol or keyword. I'm ...
0
votes
0answers
25 views

Emacs flashes when changing buffer with `ido-switch-buffer`

When I change buffer via ido-switch-buffer and enter a python buffer my entire Emacs flashes visually for a second. If I handle other files the same way, it does not. What can be the reason for that? ...
0
votes
1answer
51 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
35 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
27 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
1answer
52 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
64 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
35 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
21 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 ...
2
votes
0answers
99 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
247 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
201 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
71 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
74 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
22 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
37 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
496 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
107 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
66 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
71 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
102 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
107 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
100 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
51 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
120 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
94 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
30 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
216 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 ...
1
vote
0answers
371 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
88 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
650 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
47 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 ...
2
votes
2answers
271 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 ...