Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
3 votes
2 answers
2k views

elpy [No match] when installing package

I'm trying to follow the instructions in the README of this repo: https://github.com/jorgenschaefer/elpy . Everything goes smoothly until I get to the point where I am to install the package. After ...
0 votes
1 answer
269 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
1 answer
517 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
1 answer
63 views

Completely removing all python-shell functionality

I'm running emacs 27.2 under Linux. I want to totally and completely remove all python-shell-* functions. I know how to unmap the python-shell-related keymappings, but I want to go further and remove ...
0 votes
1 answer
330 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
1 answer
61 views

How to evaluate python code in org-mode when only python3 is provided by the package manager?

Recently I started to use guix as my operating system. I installed python3 for my user via guix install python3. python itself is not available in the package repository, which I verified by running ...
2 votes
1 answer
102 views

Python mode hangs on class member comment

Emacs is freezing when trying to insert a class attribute comment when it's not at the end. E.g., class Foo: _bar: int """Some attribute.""" _biz: int "&...
0 votes
1 answer
406 views

python linting not working with eglot

System: Mac OS 12.5 Emacs 28.1 from homebrew Python 3.9.13 using a virtual env python-lsp-server For some reason my linting, with error highlighting is not working with Python using eglot. In the ...
1 vote
1 answer
2k 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', '...
0 votes
1 answer
57 views

add a new line with the same indentation level as the current line

when python code block gets larger, it's hard to find the right indentation level def foo(): for a in l: # l1 # l1-1 for b in k: # l2 print(a) # (2) print(b) ...
0 votes
1 answer
2k views

python language server with eglot - can't get it working

emacs version: 28.2 eglot version: 20221020.1010 After successfully using eglot with eglot-jl for some time when programming in julia, I now have to use python for a few small tasks, and I was looking ...
10 votes
3 answers
2k views

How can I make python-mode correctly indent python's match statement?

Python 3.10 added a match statement. When I try and type one in emacs 27.2, it does not indent it correctly, presumably because it does not yet have support for it. How do I get python-mode to ...
0 votes
0 answers
26 views

every time I run python code I get message sent: and the first line

hello I am trying to run python application on Emacs as an IDE I installed pyel and pyright from pip and package installer but now some time the result is showing and sometime it is not trying to push ...
0 votes
1 answer
143 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
1 answer
384 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
2 answers
294 views

org-mode batch export hangs when using a python session

I have developed a workflow for batch-export of org-mode files, and have come across an issue in which execution halts when using a python session. I'm using emacs 28.1 on MacOS 11.6.5 with Python 3.9....
3 votes
6 answers
352 views

__PYTHON_EL_eval_file prints in interpreter when sending python file from buffer using C-x C-l

Whenever I send the a Python buffer to the interpreter via C-x C-l it prints the file eval call as shown below. While it does print the correct output, it's a bit annoying to see it every time and I'd ...
0 votes
1 answer
58 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
1 answer
404 views

How to load python layer after direnv?

In order to have lsp-pyright load after pipenv I need pyright to load after direnv. However, appending after: direnv results in an error[0] How can I have pyright starting the workspace after direnv? ...
0 votes
1 answer
331 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 ...
1 vote
2 answers
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 ...
0 votes
1 answer
48 views

Install elpy on emacs

I checked the elpy site but came across an error where the package cannot be found? I am new to emacs and need a little help reading the error message. The specific code in the init file I tried to ...
0 votes
1 answer
22 views

use output of python code block from other python code block

My emacs is 29.2 in linux. I try below code to use output from first python block, but the output in second block is None after press C- C-c. #+name: testblock #+begin_src python print("hello&...
0 votes
0 answers
25 views

Python-mode code navigation

How can I navigate from an abstract class/method to the implementations of that class/method? Using the M-. I can jump to function definition but I can't find a way to easily find the implementation.
3 votes
1 answer
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 ...
0 votes
1 answer
102 views

ipython shell syntax error with "?" in string in `python-shell-send-string`

When in the IPython shell, ?open returns help on the "open" function. But when I send it with python-shell-send-string it throws a syntax error saying "?" is not recognised. I can ...
0 votes
0 answers
22 views

Org Mode Code Sessions Scope

I'm trying to use sessions within an org file to keep the code workspace as I need something similar in style to the Jupyter Notebooks. The issue I'm having is this isn't restricting the session to ...
5 votes
1 answer
925 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 ...
1 vote
3 answers
454 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
0 answers
30 views

Emacs Python Virtualenv Support

I am able to enable a virtual environment by adding these lines in .dir-locals.el in my project directory: ((python-mode . ((python-shell-virtualenv-root . "s:/.virtualenvs/default/")))) ...
0 votes
1 answer
36 views

How to move out of a python string with C-M-u

I'm used to using backward-up-list to go to the front of a string in most every programming mode, but for some reason it doesn't work in python-mode. python-mode rebinds C-M-u to its own python-nav-...
0 votes
2 answers
368 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 ...
2 votes
1 answer
321 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
1 answer
19 views

change the tag of the exported code

I want to change the exported tag of #+begin_src python .. #+end_src exports to \begin{verbatim} ... \end{verbatim} I want it to be export to \begin{python} \end{python} Anyone has any idea ?...
0 votes
1 answer
283 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
1 answer
2k views

How can I add the current directory to `PYTHONPATH` automatically?

I use elpy and I am not able to use relative paths to access files because the PYTHONPATH doesn't include the directory I'm in by default. I may have set it up wrong in elpy-config. Here are my paths ...
1 vote
1 answer
525 views

How to autocomplete dynamically created objects in python code?

Is anybody able to get suggestions after typing x. using code below? E.g. name import json from types import SimpleNamespace data = '{"name": "John Smith", "hometown": {&...
0 votes
1 answer
168 views

elpy/pyvenv: "JSON readtable error: 80"

Trying to use elpy, I cannot get to run neither elpy-config nor pyvenv-workon commands that I get this error message in the minibuffer. Steps: open a python file M-x pyvenv-workon RET dev RET where ...
3 votes
1 answer
2k 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 ...
2 votes
1 answer
578 views

No numpy, scipy, sympy and matplotlib minor-modes?

Python scientific libs are immensily popular for the last decade or so. However googling and "melping" for its emacs minor-modes reveals nothing. Basically I need just syntax highlighting. Do you ...
0 votes
1 answer
283 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: ...
1 vote
1 answer
124 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 ...
0 votes
1 answer
37 views

fill-region fails as fill-forward-paragraph complains about argument type

I am trying to fill a region within a Python docstring. The function find-docstring-limits returns the limits of the docstring. Here is the function: (defun indent-docstring-paragraph () "...
0 votes
1 answer
37 views

Defining custom Python skeletons

I'm trying to define a custom Python skeleton and have found there are two macros in python.el that might be of use here. After poking around and looking at the value for python-skeleton-autoinsert it ...
4 votes
2 answers
366 views

macos org-babel python with session output give __PYTHON_EL_eval

#+begin_src python :session :results output print("yes") #+end_src With org-babel-execute-src-block command, the result is: #+RESULTS: : __PYTHON_EL_eval("try:\n with open('/var/...
0 votes
0 answers
38 views

Python parenthesis folding in doom emacs

I run into situations a lot where I have code that looks like new_stuff = ( blah.blah ( stuff, stuff, stuff, stuff, ).blah_two( [morestuff, stuffstuffstuff, stuffffff ] ) ...
0 votes
1 answer
1k views

configuring spacemacs for python development

It's been really frustrating trying to get spacemacs to work so far. I've grown to really love it - coming from vim - for its capabilities in manipulating and navigating text, but it's just been so ...
0 votes
1 answer
1k views

Get process id (pid) for running python (jupyter-kernel)

I've started a jupyter kernel form emacs-jupyter. I'd like to get the process id for the python process associated with the buffer so that I can attach a debugger to it. How can I do this in elisp?
2 votes
2 answers
223 views

How do I make emacs find `ac-source-pycomplete`?

I followed Jessica Hamrick's emacs setup before adding evil. This means that there is a lot of specific configuration issues in my ~/.emacs.d/ which I don't necessarily understand, shame on me, but ...
0 votes
0 answers
28 views

Python Code executes, but result screen shows a long line of characters

So my professor is obsessed with emacs and has encouraged us to set it up on our personal devices. Under his guidance I downloaded it, and he gave us some homework in a .org file. Inside this file, we ...

1
2 3 4 5
13