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.

177 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7
votes
0answers
923 views

show output from python-shell-send-region

Using python.el and ipython.exe (from Miniconda3), I'd like to highlight a portion of code and execute it in the associated inferior python buffer. Example: #!/usr/bin/python3 myvar = 100+200 ...
7
votes
2answers
182 views

Syntax highlighting fails on clone-indirect-buffer-other-window

I normally use indirect buffers while I edit python code in python-mode, I create them by running clone-indirect-buffer-other-window. While the syntax highlighting of the main buffer looks just fine, ...
6
votes
0answers
165 views

xref unsuccessful in python buffers: “no definition found”

The command xref-find-definitions is no longer working for me in Python buffers (with elpy-mode enabled. Its companions, such as xref-find-references, are also not working in Python buffers. ...
6
votes
0answers
161 views

Incorrect filling of Python docstrings in pep257 mode

I have python-fill-docstring-style set to pep-257 (default) and I'm trying to fill docstring paragraphs. However, python mode does not count """ towards the number of characters, nor does it consider ...
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 ...
5
votes
0answers
1k 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 ...
5
votes
1answer
704 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 ...
5
votes
0answers
300 views

Ropemacs default refactoring

I'm performing a large python refactor, and one component of that is renaming many variables from camelCase to snake_case. I'd like to hook a camel-to-snake conversion function (which I already have) ...
4
votes
0answers
258 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 ...
4
votes
0answers
417 views

list of current variables in a buffer for Python code

I would like to find a way to reproduce the "Workspace" of Matlab or the equivalent "Variables" window of the awesome pudb debugger directly in emacs for python code: it is a window which details the ...
4
votes
0answers
275 views

Is it possible to debug Django from gud-pdb?

Brand new to gud/pdb and I am trying to run the Django development server from emacs. I can't seem to set breakpoints that affect the running server, though. I am invoking PDB with M-x pdb, then ...
4
votes
0answers
288 views

Org-babel and anaconda-mode in src blocks

I practice python literate programming with tangling to generate a full project structure. There are dependencies between modules and packages, and so I will say in the C-c ': #+begin_src python ...
4
votes
0answers
844 views

Org mode python session does not return a file name

In the following link you can find the following simple example: #+begin_src python :session :results file import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt fig=plt.figure(...
3
votes
0answers
434 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 ...
3
votes
0answers
71 views

Python automatically add import statement

Is there a way to automatically add imports to python code within emacs? def f(x: str) -> List[str]: I want to be able to have my guess over "List" press a key binding and magically add ...
3
votes
0answers
911 views

debugging: how to optimize a RealGUD workflow

I code in Python and I my workflow uses debuggers (I coded for 8 years in Matlab). I develop numerical simulation codes: most of the time it returns a result, the question is: "Is the result right?" ...
3
votes
1answer
1k 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 ...
3
votes
0answers
129 views

how to highlight imported functions in python code?

python-mode or elpy-mode in Emacs only highlight the basic Python library functions. If you work a lot with other libraries like numpy and matplotlib, would be nice to have these functions and ...
3
votes
0answers
159 views

How to connect to remote python with jedi.el?

How can I connect to remote python with jedi.el? I need to use remote virtualenv for getting possible completions, docs, etc.
3
votes
0answers
260 views

Automatically use appropriate Python version with Jedi.el

Documentation says that it can be done by making some variables buffer local. But how to make it correctly? Can somebody show me example how to configure this jedi.el behaviour correctly? Now I have ...
3
votes
2answers
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 ...
3
votes
0answers
2k views

emacs as python IDE vs pycharm: spacemacs and code navigation

[2016.12.23]: I'm trying to make emacs be usable for working with python code. By 'usable' I mean I could rely on it with code navigation and completion. I'm using spacemacs + anaconda-mode for it, ...
3
votes
0answers
168 views

Org-babel noweb expansion when sending C-c ' buffer to python shell

I'm doing literate programming with Python. In my workflow I like to test the block with python-shell-send-buffer and ipdb debugger. However if the block contains a noweb reference then the code is ...
3
votes
0answers
1k views

How to use the auto-completion of jedi while keeping other functions of elpy?

Currently, I have both elpy and jedi installed. init.el is like: (elpy-enable) (elpy-use-ipython) (setq elpy-rpc-backend "jedi") (add-hook 'python-mode-hook 'jedi:setup) (setq jedi:complete-on-dot t)...
3
votes
0answers
385 views

Unexpected Indentation in Python interpreter

I am getting an indentation error in the Python interpreter while using elpy: >>> for i in range(1, 3): ... print(i) File "<stdin>", line 1 print(i) ^ IndentationError: ...
3
votes
0answers
149 views

Remove extra prompts in inferior-python-mode with ipython

emacs24.5 -Q M-: (setq python-shell-interpreter "ipython") RET M-x run-python RET Python 3.5.1 (default, Dec 7 2015, 12:58:09) Type "copyright", "credits" or "license" for more information. ...
3
votes
0answers
97 views

Make fill-paragraph in *raw* python docstring leave the triple-quotes on separate line

This is almost the same question as this one, but not quite. I happen to like the docstring style def f(): """ docstring another line """ so in emacs I have python-fill-docstring-...
3
votes
0answers
65 views

Indent parenthesized Python expression

I have emacs set up to indent Python code like so: foo( bar, baz ) That works fine. However, that style in a particular program I'm working on very often means I find myself with text like this:...
3
votes
0answers
329 views

Set up Jedi with virtualenvwrapper

I'm using a virtualenvwrapper setup for Python. On my emacs, I have virtualenvwrapper and jedi installed from MELPA. What I currently do is, I open Emacs, M-x venv-workon RET blabla RET, then M-x ...
3
votes
0answers
284 views

Undesired auto expansion with company-mode and python-mode

I am using company-mode and python-mode (note the same issue does not happen with python.el) and something about the combination is causing emacs to automatically expand at point. For example, if I ...
2
votes
0answers
41 views

See mypy type of what's under point

Is it possible to see mypy types in emacs? I would like a command that does something like show the type of what's under point (presumably getting that information from the mypy cache for speed?). ...
2
votes
2answers
282 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: ...
2
votes
0answers
38 views

How to move by defun without moving up a level?

I am attempting to navigate methods in a file. Typically these are javascript or python files, which have a classes at the "top level", which in turn have methods nested within those ...
2
votes
0answers
45 views

What is the flying trashcan icon replacing colons in Python buffers?

There is a strange icon appearing in place of colons (:) in my Python buffers. I cannot identify it easily using C-x = or any other command to inspect the character at the point because the icon ...
2
votes
0answers
265 views

flycheck - elpy - flake8 - ein and .ipynb files

I have set up Emacs (on Mac Catalina) with Elpy to handle Python. I also managed to get Jupyter notebooks (.ipynb files) working with Elpy via Ein. Both .py and .ipynb compile and use Flycheck ...
2
votes
0answers
317 views

Jedi fails to start Jedi EPC Server because python 3.8 is installed and 3.7 not

Is the only solution to downgrade python 3.8 to 3.7 or wait till it is supported? Or are there other options? The error message is this: Error (jedi): ================================ Failed to start ...
2
votes
0answers
405 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 ...
2
votes
1answer
234 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: : /|...
2
votes
0answers
167 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 ...
2
votes
0answers
141 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 ...
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 ...
2
votes
0answers
266 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 ...
2
votes
0answers
60 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. ...
2
votes
0answers
291 views

Lisp nesting exceeds max-lisp-eval-depth in python-mode 6.2.3, Emacs 25.2

I have this simple Python test program: #! /usr/bin/env python3 import numpy as np x = np.array([0, 1, 2, 3]) y = np.array([0, 1, 4, 9]) def gen_segments(x, y): for i in range(0, len(x)-1): ...
2
votes
0answers
192 views

Output of ipython shell much slower than python shell

Even turning off font-lock-mode and set (setq python-shell-font-lock-enable nil), the output of an ipython shell (setq python-shell-interpreter "ipython") seems much slow than the python shell (...
2
votes
0answers
369 views

highlight-indentation-mode discontinue

I am using spacemacs. When enabling highlight-indentation-mode in python-mode, I found that the vertical lines are not continue, they will be interrupted if there is an empty line. How can I fix this?
2
votes
0answers
198 views

How to find/grep in Python virtualenv with projectile/helm easier?

How I can customize helm/projectile behaviour to find files and grep in $VIRTUALENV dir easier? Or maybe I can write some function(s) to find/grep in virtualenv of current project?
2
votes
2answers
190 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 ...
2
votes
0answers
258 views

Send Python Buffer to ansi-term

I recently started using emacs to code in Python. I currently prefer to use python mode (defined in python.el) alongside ansi-term for the python interactive shell. I'm trying to change the behavior ...
2
votes
0answers
457 views

elpy-importmagic-add-import without rearranging imports?

The auto-importing functionality of elpy is awesome. However, it rearranges all the previous import statements in the file alphabetically. This is problematic for me because: I prefer to arrange my ...