Hot answers tagged

26 votes
Accepted

Using conda environments in emacs

I'd suggest using pyvenv library, it provides a neat interface to selecting a virtual env among several alternatives updating interpreter and library paths. You will need to alter WORKON_HOME variable ...
immerrr's user avatar
  • 554
25 votes
Accepted

Python org-mode source block output is always ': None'

This is a peculiarity of how babel handles some languages. This gives some detail on python, and a complete list of options is available here. There are quite a few useful ones. Basically, depending ...
user2699's user avatar
  • 2,201
24 votes

Python org-mode source block output is always ': None'

In a very simple case like this one, there's a hack I tend to use, replace print with return: #+BEGIN_SRC python return "hello" #+END_SRC #+RESULTS: : hello But in general the better solution will ...
Brian Z's user avatar
  • 2,893
16 votes
Accepted

org-mode: how can i point to python3.5 in my org-mode doc?

I discovered that just setting in the file: ~/Library/Preferences/Aquamacs Emacs/Preferences.el (setq org-babel-python-command "python3") Does the job. However, i don't really understand why it ...
Cy Bu's user avatar
  • 481
12 votes
Accepted

Which class or method or function am I in?

which-function-mode displays the current method name. The following configuration, which I got from Emacs Redux, displays the current method / function / orgmode heading in the top header line rather ...
Juancho's user avatar
  • 5,435
12 votes
Accepted

Library for automatically inserting python docstring in Google style

Package The code described in the following section have now been made available in a separate package. Please see this repository for details: https://github.com/Xaldew/yasnippet-radical-snippets. ...
Xaldew's user avatar
  • 1,201
12 votes

Your ‘python-shell-interpreter’ doesn’t seem to support readline

If you don't want to get a 25.2 rc, you can apply the bug fix by adding this to your init.el file: (with-eval-after-load 'python (defun python-shell-completion-native-try () "Return non-nil if ...
npostavs's user avatar
  • 9,083
11 votes
Accepted

Is there a way to use python instead of elisp for extending emacs?

As Tephra said, Pymacs is a package designed for this. It's an interface between Python and Emacs Lisp. The project isn't very active but from what I understand it's fully functional with the latest ...
JCC's user avatar
  • 999
11 votes

Exporting highlighted source code to pdf in Org-Mode

Hey this answer solved my similar problem. A bit late but I had the same issue today. As mentioned, I add the following code snipped to my .spacemacs/.emacs config: (require 'org) (require 'ox-latex)...
Oyren's user avatar
  • 221
11 votes
Accepted

How to highlight in different colors for variables inside `fstring` on python-mode

I think this will do it for Emacs versions < 27.1 (require 'python) (setq python-font-lock-keywords (append python-font-lock-keywords '(;; this is the full string. ;; group ...
John Kitchin's user avatar
  • 11.6k
10 votes

How do use Emacs to look up a function in Python?

The feature of PyCharm that you mention was one of my favourites, and one of the first things I looked for in trying to replace PyCharm completely with Emacs (which I am happy to say I have been able ...
elethan's user avatar
  • 4,775
10 votes
Accepted

Spacemacs use anaconda environment

Basically, this is a duplicate of this question. Reproducing the proposed behavior with spacemacs, I changed my user-init to: (defun dotspacemacs/user-init () (setenv "WORKON_HOME" "/home/<...
Michael Gecht's user avatar
9 votes
Accepted

Multiple major modes in one buffer (e.g., python-mode & LaTeX-mode)

MMM-mode (multiple major modes) seems exactly what you're looking for. It is mentionned on the emacs wiki. You need to define a submode class to mix LaTeX and python, specifying that python parts ...
JeanPierre's user avatar
  • 7,363
8 votes

How to set up elpy to use python3?

You can solve this by modifying the python shell configuration from python to python3 in elpy-config M-x elpy-config to enter the configuration page of elpy if you scroll down you will see groups ...
oksuzgonul's user avatar
8 votes

How do you create a robust Python IDE with Emacs (as the Text editor)

Here is a comprehensive guide: http://wikemacs.org/wiki/Python It lists ready-to-use solutions (the Prelude starter kit, Spacemacs, solutions for data science,…), big useful packages (Elpy), as well ...
Ehvince's user avatar
  • 1,091
8 votes
Accepted

spacemacs flycheck: use specific linter for python

Replace your relevant configuration with this: (add-hook 'python-mode-hook (lambda () (flycheck-mode 1) (semantic-mode 1) ...
elethan's user avatar
  • 4,775
8 votes
Accepted

Library that converts a Python output string to an Elisp data structure?

Use JSON, not Python syntax What you are looking for is json.el which is a part of Emacs. Note that it will not read Python format OOTB; there are at least 3 problems: 'foo' is not recognized as a ...
sds's user avatar
  • 5,958
8 votes

Using conda environments in emacs

I have recently incorporated Anaconda into my python development and was having similar problems setting up Emacs + flycheck + linters. This answer got me up and running, but I've modified it, since ...
Jim Parker's user avatar
8 votes

Is there a way to use python instead of elisp for extending emacs?

You can extend Emacs in other languages, like Haskell and OCaml. There's a discussion on Reddit about advantages and disadvantages of doing so. In short, I don't think it's a good idea to use other ...
Tianxiang Xiong's user avatar
8 votes

Get pandas data-frame as a table in org-babel

Update for people reading this in 2020 You can now use tabulate Python package and write: #+begin_src python :results value raw :return tabulate(df, headers=df.columns, tablefmt='orgtbl') from ...
ldc's user avatar
  • 221
8 votes

Specifying python version in run-python

Put (setq python-shell-interpreter "python3") into your .emacs.
vanden's user avatar
  • 221
8 votes
Accepted

Python in org babel will not work

Ah. It's entirely possible python is actually working; depending on exactly how you've set up your python src blocks in Org, you may simply not be getting any results. You may know this already, but ...
Gastove's user avatar
  • 1,521
8 votes
Accepted

How do I suppress messages in the echo area (e.g. `Fill column set to 80 (was 80)`)?

@NickD answered the question well. But you can also do this, just to inhibit showing messages for set-fill-column: (add-hook 'python-mode-hook (lambda () (setq indent-tabs-mode ...
Drew's user avatar
  • 76.4k
8 votes
Accepted

Org mode python code block with session does not return a result

The python implementation in Org babel has a couple of long-standing problems: If you specify :results value, then the body is implicitly wrapped in a function and you have to add a return statement ...
NickD's user avatar
  • 28.2k
7 votes
Accepted

How to keep underscores in Python within a word boundary?

Add a hook to modify the python-mode-syntax-table: ;; Keep underscores within a word boundary (add-hook 'python-mode-hook (lambda () (modify-syntax-entry ?_ "w" python-mode-syntax-table)))
Jeff Bauer's user avatar
7 votes
Accepted

Trouble adjusting tab-width

The first line when enabling python-mode is (set (make-local-variable 'tab-width) 8). Because tab-width is a buffer-local variable, a new value would need to be set subsequent to the code above. The ...
lawlist's user avatar
  • 18.9k
7 votes

How do you create a robust Python IDE with Emacs (as the Text editor)

I use purpose-mode. This allows you to define a pretty robust environment. Using elpy, pydoc, and neotree I have a pretty robust environment (in the sense that windows don't do strange things at ...
Nidish Narayanaa's user avatar
7 votes

Get pandas data-frame as a table in org-babel

Here is one way to achieve what you want I think. The key is constructing a list that has what you want in it. #+BEGIN_SRC python :exports both :results value table :return test2 import pandas as pd ...
John Kitchin's user avatar
  • 11.6k
7 votes
Accepted

org-src-mode send commands to repl in named python :session, not *Python*

This is really hidden and (to my knowledge) not documented so caveat emptor … At the very end of org-edit-src-code I found the following snippet: (let ((edit-prep-func (intern (concat "org-babel-...
purple_arrows's user avatar
7 votes

Dedicated Python Shell?

OK, so I figured this out (thanks largely to this answer). Now, rather than simply typing C-c C-p, I use C-u C-c C-p to get the options of specifying the Python command I want, and to select a ...
farenorth's user avatar
  • 221

Only top scored, non community-wiki answers of a minimum length are eligible