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
2answers
25 views

Why is my Python indentation set to 8 locally by default?

I'm running Emacs 25.2.2 on Ubuntu 18.04 for WSL. I launch emacs -q and open a new Python file, test.py. As soon as I hit the Tab key, I notice the indentation is 8 spaces instead of 4. I don't like ...
0
votes
1answer
16 views

How to unpack a tuple from org-sbe evaluating a python code block into multiple columns of a org-table?

I often encounter situations where I can easily think of python code that, given some input values, computes multiple output values at once. As an example, consider the following simple code-block ...
3
votes
2answers
117 views

How can I make python3 the default in Emacs 25.2.1?

I do have python3 on my laptop. $ sudo find / -name "python3" | python3-locations.org (partial list of locations) /usr/local/bin/python3 /usr/lib/python3 /usr/share/doc/python3 /...
0
votes
0answers
25 views

Is there a pexpect like automation for serial-term or term-mode

Is there something similar to pexpect that can be used to automate a tty connection running inside emacs, i.e. in term-mode or on top of serial-term ? I'd like to automate some repetitive tasks like ...
0
votes
1answer
76 views

Running lsp-mode with Python using the pyls from the virtualenv of my project

I wish to run LSP using the pyls from the virtualenv of my project. I don't have pyls installed globally (only in the local virtualenv). I found this snippet online: (lsp-define-stdio-client lsp-...
0
votes
0answers
22 views

C-x C-f causes python shell to start in python-mode

I normally use C-x C-f to counsel-find-file by every time I try using it in python-mode, it starts up the Python Shell in a buffer. I've tried investigating whether there is a hotkey conflict using "C-...
0
votes
1answer
35 views

Evaluate single line of python code from Emacs org-babel

Consider a block of python code in an org-mode document: #+begin_src python num1 = input("Enter a number: ") num2 = input("Enter another number: ") result = float(num1) + float(num2) print(result) #...
0
votes
0answers
21 views

What are the steps to set up elpy to use the anaconda python distribution on Windows?

I have anaconda installed on Windows (Windows 7), and it is working well in Jupyter. But of course I'd prefer to work in emacs. I have elpy installed in emacs, and it successfully sends commands to ...
1
vote
1answer
36 views

Remove extra prompts in Emacs Babel Python session

When I run the following code block from Emacs org-babel: #+BEGIN_SRC python :session *Python* :results output print("Hello World") #+END_SRC This is what prints out in my *Python* session: >...
1
vote
1answer
37 views

Org-babel python with session breaks output

If I run the following code block: #+BEGIN_SRC python :results output print(" /|") print(" / |") print(" / |") print("/___|") #+END_SRC I get the result as expected: #+RESULTS: : /|...
0
votes
0answers
15 views

Switch between anaconda and venv using pyenv-workon

In my emacs config, I have (setenv "WORKON_HOME" "/anaconda3/envs") however I am now in a situation where I need to use an environment created by venv located in the Python project's root ...
0
votes
0answers
28 views

Jedi EPC server - make client process fails

Recently my Emacs/Python setup stopped working as it had done previously without any problem. I have the following defining where my virtual environments are in my init files... (setq venv-location (...
1
vote
1answer
34 views

company-lsp complains about void function lsp--client-completion-in-comments

my emacs lsp-python setup is pretty standard: (require 'lsp-mode) (add-hook 'python-mode-hook #'lsp) (require 'company-lsp) (push 'company-lsp company-backends) (add-hook 'after-init-hook 'global-...
0
votes
0answers
91 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
24 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
26 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
30 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
19 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
37 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
41 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
45 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
33 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
79 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
81 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
94 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
127 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
45 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
93 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. ...
4
votes
1answer
169 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
27 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
84 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
36 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
31 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
65 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
82 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
38 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
22 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
104 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
331 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
229 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
113 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
82 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
24 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
42 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
638 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
118 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
80 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
95 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 ...