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

Any equivalent of R+ESS for python?

I do a lot of R coding on Emacs – on Windows – using the wonderful ESS package. What I particularly like is that I can: start an R session, and then send lines or regions of the script I'm working on ...
0
votes
1answer
16 views

Emacs (ipython) inferior python shows strange input numbers

In emacs, I use ipython in the inferior python mode with config: (setq python-shell-interpreter "ipython" python-shell-interpreter-args "--simple-prompt -i") When I edit my .py file, without any ...
0
votes
1answer
68 views

Make buffer unreachable

This may be a silly question, but how can I make a buffer unreachable? I have enabled live-py-mode. Every time I try to edit my python file it evaluates the code, which is a well and good but it's a ...
1
vote
0answers
16 views

org-babel python :session names matter

For example, I get #+BEGIN_SRC python :session sdfjkl :results output import numpy #+END_SRC #+RESULTS: : Python 3.8.0 (default, Oct 23 2019, 18:51:26) : [GCC 9.2.0] on linux : Type "help", "...
1
vote
1answer
42 views

Why needs syntax highlighting often a `revert-buffer`?

Quite frequently, syntax highlighting in a given buffer is broken (i.e., a big fraction of the code is not highlighted). This is definitely not due to syntax errors, and the point at which ...
0
votes
0answers
30 views

disable automatic python file scrolling if using blacken or yapfify

I am using blacken to automatically format my python files (use-package blacken :demand t :after python :init (add-hook 'python-mode-hook 'blacken-mode) ) (use-package python :mode ("\\.py\\'" ...
0
votes
2answers
37 views

Emacs occasionally using wrong indent in python

I have a bunch of python files (ie .py files), which I use Emacs to edit. However I keep having the issue where sometimes emacs will indent regions with 8 spaces instead of 4, and I can't figure out ...
2
votes
1answer
63 views

“Backspace” key sometimes also deletes forward in python-mode

Start Edit 1 To answer questions. Emacs Versions: GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK+ Version 3.22.21) of 2017-09-22, modified by Debian GNU Emacs 26.3 (build 1, x86_64-w64-mingw32) of 2019-...
-1
votes
1answer
45 views

Autocomplete suggestions after dot in python using company-mode

Jedi has support for auto-completion after dot (setq jedi:complete-on-dot t) => Main goal is to Finding what methods a Python object has [Q] Does company-mode has the same support (complete-on-dot)?...
0
votes
1answer
19 views

Elisp to get the language mode for the current ein cell?

When I'm using ein to run a python jupyter notebook, the major-mode variable is just "ein:notebook-multilang-mode" which makes it ambiguous what the current language is. I have elisp that only ...
1
vote
1answer
19 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 ...
6
votes
1answer
162 views

How to highlight in different colors for variables inside `fstring` on 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
2answers
37 views

How to navigate to the next/previous python class?

I would like to navigate quickly between classes in Python code. I'm looking for a command to go to the next / previous class so I can bind that to a key sequence. This question is not about ...
1
vote
0answers
39 views

How to read the python documentation offline in emacs?

Sometimes I use ctrl h i or M-x woman, though I almost always head to the web for basic queries like python find line in string. Do I need to download this[0], that[1] or something else before leaving ...
0
votes
0answers
78 views

Unable to get microsoft python-language-server to work lsp-mode

Here is my python config As soon as I open a python file, I get this error: LSP :: Microsoft Python language server started LSP :: Microsoft Python language server is analyzing...done File mode ...
1
vote
1answer
112 views

python interpreter within emacs fails on simple test on __main__ (syntax error)

This small program runs well in Terminal : mac2011% cat bug.py print(__name__ == "__main__") #if True: if __name__ == "__main__": print("main") else: print("not main") mac2011% python bug.py ...
0
votes
1answer
38 views

how can I change the inferior Python process

I would like to be able to start Python 3 and ipython from Emacs in an inferior mode buffer. Currently start interpreter C-c C-p starts 2.7. I know there must be a way to change to start another ...
0
votes
2answers
54 views

How to save and execute a python file?

I do not prefer python-mode. I would like a generic way so that I can understand emacs. I wish the file be saved and python file command then be run as if in a shell.
1
vote
0answers
106 views

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

Are the only solutions 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 ...
1
vote
1answer
32 views

Auto fill of # style comments in Emacs python-mode not working

My expectation is that, like for comments in other language modes besides python, I could write a long comment, say 150 chars, and it would automatically fill, i.e., newline and indent with comment ...
0
votes
0answers
20 views

Python indent closing parentheses for multi-line function

I've discovered some reformatting with Black or Yapf: def responses(self, foo=SuperLongClassnameBar.FOOBAR ) -> List['Foobar']: Using emacs and elpy, it won't indent the closing ...
0
votes
0answers
33 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
46 views

How to edit code in the source window using realgud?

I've started using realgud:pdb for python debugging in emacs: https://github.com/realgud/realgud When you begin a realgud session, it opens a command window and a source window. Keys like 'n' and 'b'...
1
vote
0answers
56 views

Identation issues in python mode

almost everytime, I cope e.g. snippets from the web and paste it with M-w in a python buffer the indentation is all wrong. Sometimes slanted to the left, sometimes to the right. Often all of the ...
1
vote
0answers
59 views

Set RPC Python when using elpy with virtualenv

I'm having trouble getting my elpy setup to work smoothly. My current config is: Elpy Configuration Virtualenv........: (/home/jeff/Documents/Proj/myenv/bin/) RPC Python........: 3.7.3 (/usr/bin/...
0
votes
1answer
28 views

In spacemacs, how do I copy code from the history in python REPL to my window which has a python source code file open?

I'm new to spacemacs -- I'm using it as a Python IDE. I'd like to know if there is an easy way to copy lines from the history on a REPL back to the source-code window. The idea is, I prototype in ...
2
votes
1answer
46 views

What's the idiomatic way of overriding a key binding for a given major-mode (but no other)?

I'd like to bind C-x C-e to python-shell-send-region when I am in python major-mode. In my config file, I have an add-hook for python mode, but I'd like this keybinding override to be removed/...
0
votes
1answer
36 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
32 views

Run-python problem Emacs + Anaconda (virtualenv)

When I used run-python through 'c-c c-p', I got the messages like below. I don't know what it is. Anaconda within GNU emacs in Mac. It doesn't seem like a problem, just came out.
1
vote
1answer
215 views

Python shell warning about readline and completion?

*Warning*: Warning (python): Your ‘python-shell-interpreter’ doesn’t seem to support readline, yet ‘python-shell-completion-native-enable’ was t and "python3" is not part of the ‘python-shell-...
0
votes
2answers
63 views

Python and electric-indent: newline autoindent disregards previous blank line

This is (yet) another question related to electric-indent-mode and Python, but since I couldn't find what I address here in the other ones, here we go. I find the behavior of electric-indent-mode ...
1
vote
0answers
24 views

Why does this org session src block not give me the right results?

I am trying to up my literate coding chops and solving some programming challenges with it. Here is the full writeup of the exercise I'm playing with Mostly everything works and I understand ...
1
vote
1answer
129 views

Stop company-lsp from completing function arguments

I try to configure lsp-mode and company-lsp with python-language-server for python autocompletion, but when I choose completion candidate it completes with function arguments. How can I prevent this ...
1
vote
1answer
107 views

emacs lsp-mode python how to disable certain warnings

lsp-mode complies to PEP8 style guide I guess, but how can I disable certain warnings, e.g. about missing docstrings etc.?
0
votes
2answers
64 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
39 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
488 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
33 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
902 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
47 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
133 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
191 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
70 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
92 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
48 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
101 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
152 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-...
2
votes
2answers
741 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
1answer
96 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
91 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?

1
2 3 4 5
9