Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Build Status License: GPL v3


npy.el is a set of nano (or minimalistic) extensions to the Python development support in Emacs. Its first goal is to provide a nice integration of Pipenv virtual environments and Emacs inferior python modes. For instance - spawning multiple inferior python processes for multiple Pipenv projects, and dispatching Python code chunks sent from a buffer, which is visiting a Python file in one of the Pipenv projects, to the inferior python process bound to the virtual environment of the same Pipenv project. We call this new type of inferior processes virtualenv-dedicated inferior python processes.

Some of npy.el's features:

  • spawn a virtualenv-dedicated inferior python process for a Pipenv project
  • send a Python code chunk from multiple Python file buffers in a Pipenv project to the virtualenv-dedicated inferior python process for the project
  • dispatch Python code chunks to appropriate virtualenv-dedicated inferior python processes when you have spawned multiple virtualenv-dedicated inferior python processes for different Pipenv projects
  • spawn a viartualenv-dedicated inferior python process associated only with a python-mode buffer. We call this type of processes virtualenv-buffer-dedicated inferior python processes
  • change buffer's association to a Pipenv project automatically when you write out the content of the buffer as a file under other Pipenv project
  • spawn a python scratch buffer associated or associatable with a virtualenv-dedicated or virtualenv-buffer-dedicated inferior python process. We call this type of scratch buffers virtualenv-dedicated or virtualenv-buffer-dedicated python scratch buffers
  • spawn a Pipenv shell for a Pipenv project


Ensure you have four elisp packages, f.el, s.el, nalist.el, and gpc.el, installed in your Emacs prior to the npy.el installation. You can get f and s from MELPA or Github, and nalist and gpc from Github.

Place npy.el on a directory in your `load-path', and add this to your Emacs config:

(require 'npy)

The initial keymap prefix C-c ' is just a suggestion. Feel free to customize npy-keymap-prefix to whatever works best for you.

Basic Usage

npy-mode is automatically enabled when you open a Python file, i.e. it's hooked to the python-mode.

When npy-mode is turned on, the mode line shows the Pipenv project the file the buffer is visiting belongs to. The lookup for a Pipenv project in the system usually happens when you visit the file. The mode line looks like Py[v:hello_world] where 'hello_world' is the name of the Pipenv project.

Spawn an virtualenv-dedicated inferior python process by C-c ' p or M-x npy-run-python. Its buffer name should be *Python[v:hello_world]*.

Hereafter npy-mode works transparently: you can use all the interaction between buffers visiting Python files and the inferior python mode as in an ordinary python-mode buffer.

Additionally, you can spawn a buffer-dedicated inferior python mode with access to the virtual environment by putting any prefix args to M-x npy-run-python or C-u C-c 'p. The mode lines look like Py[v:hello_world;] and *Python[v:hello_world;]* respectively. This type of inferior python processes only associated with the python-mode buffer where it spawned. Other buffers visiting files in the same Pipenv project can't send code chunks to the process.

Note: The python-mode defines two types of inferior python processes: global and (buffer-)dedicated. Their precedence order is:

buffer-dedicated > global

The precedence order in npy.el, which introduces two additional two types: virtualenv-dedicated and virtualenv-buffer-dedicated, is:

virtualenv-buffer-dedicated > virtualenv-dedicated > buffer-dedicated > global

We might change this in a future release.

You can spawn a scratch buffer for python-mode with access to a virtualenv-dedicated or virtualenv-buffer-dedicated inferior python process by M-x npy-scratch.

Spawn a Pipenv shell by C-c ' s or M-x npy-shell.


  • It slows down your Emacs startup process when you restore lots of Python files with desktop-mode.

Known issues

To be available when posted.


A changelog is available here.


Copyright © 2019 Cyriakus "Mukuge" Hill

Distributed under the GNU General Public License, version 3


Extensions to Python development support in Emacs.




No packages published