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
1
vote
1answer
20 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. --...
1
vote
4answers
2k views

How to run blocks/cells of python code in emacs?

https://i.stack.imgur.com/TIxlR.png The picture shows what I mean by "block" - I mean a cell of code that is delimited by some sequence of characters, in this case '#%%', that can be executed by the ...
0
votes
0answers
7 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
12 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
23 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
55 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 ...
3
votes
1answer
540 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
1answer
367 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 ...
11
votes
4answers
8k views

Library for automatically inserting python docstring in Google style

I'm looking for an elisp package that automatically inserts Python docstring for a method. I found a package, which is very close to my purpose. But it's in reStructured text, not in Google style. ...
0
votes
1answer
95 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
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 ...
2
votes
1answer
250 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: : /|...
1
vote
1answer
309 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 ...
1
vote
1answer
238 views

Python-Repl issues with TRAMP Mode [windows->Linux]

I have an issue when using python-mode remotely through tramp. I'm trying to use the repl and pass a test function using C-c C-c, however this seems to create a local file at my own computer or ...
0
votes
1answer
38 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 ...
0
votes
1answer
193 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
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
1answer
1k views

getting Jedi to work with type hinting (Python)

I am trying out the Python 3 type hinting with this example: from typing import List def greeting(names: List[str]) -> str: return 'Hello, {}'.format(', '.join(names)) greeting(['jane', '...
1
vote
2answers
1k 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 ...
6
votes
1answer
2k views

How do I change the working directory used by pdb/gud?

When running M-x pdb from Emacs, the current directory seems to be set to that of the directory of the script you are running, so pdb ~/path/to/project/__main__.py Would set the working directory ...
2
votes
1answer
62 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
1answer
236 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
0answers
14 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
16 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, ...
3
votes
1answer
2k views

python "WORKON_HOME" not showing virtual environments in helm

I've check to see my WORKON_HOME env is set to where I want it at /home/user/anaconda3/envs but in helm the only option i get is .. if I select that option Emacs thinks my virtual environment is ...
5
votes
1answer
713 views

Problem of starting a remote ipython console

I want to connect to remote ipython server, and follow the doc of the ipython, I start a ipython server in my server by ipython3 kernel -f ~/.ipython/kernel.json --pprint and I can start a ipython ...
0
votes
0answers
46 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. ...
1
vote
3answers
344 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 ...
2
votes
2answers
320 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: ...
0
votes
0answers
21 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
111 views

Can you configure python-mode, elpy-mode to apply font-locking to imported library functions?

This question is likely an expansion / duplicate of this question: how to highlight imported functions in python code? My .py file looks like this: from math import floor (max(1, 8)) (floor(3.7)) ...
0
votes
0answers
30 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
1answer
70 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 ...
0
votes
0answers
11 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
1answer
522 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
9 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
3answers
365 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. ...
0
votes
0answers
18 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-...
1
vote
2answers
278 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 ...
2
votes
2answers
1k 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
2answers
213 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
17 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
0answers
22 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
1answer
35 views

How do I open an inferior Python process in a full window from the command line?

From the command line, I want to open an inferior Python process in a full window. I have tried: emacs --eval '(run-python)', but when Emacs opens, the *scratch* buffer is shown instead of the ...
0
votes
1answer
108 views

Python for set globals()[''] variables having undefined name warning message

I am using flycheck for for Python. For global files that I set using ( globals()['variable']), and later used, it gives the following warning message: undefined name <variable> [F821] Example: ...
0
votes
1answer
162 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 ...
1
vote
1answer
54 views

How to disable hints for certain keywords in python elpy

I enabled elpy mode for python and I get hints when I type a keyword. Also I have yasnippets. Unfortunately, when I type "for" keyword, elpy gives me a useless hint, blocking <tab> key for ...

1
2 3 4 5
11