Git Product home page Git Product logo

pyenv-mode's Introduction

Pyenv mode

Melpa

Pyenv mode integrates Fabián E. Gallina's python.el with the pyenv tool. This gives packages which already use python.el (like python-django) pyenv virtual environment support out-of-the-box.

Pyenv mode does...

  • Setup the PYENV_VERSION environment variable and python-shell-virtualenv-path custom variable based on user input

Pyenv mode doesn't...

  • Override your exec-path
  • Run external shell scripts
  • Manage your pyenv installation
  • Deal with virtualenvwrapper

Installation

You can simply install the package from Melpa:

M-x package-install RET pyenv-mode

Usage

Add following block to your Emacs configuration:

(pyenv-mode)

Now you can specify the pyenv Python version:

M-x pyenv-mode-set

So now when you run inferior Python with:

M-x run-python

The process will start inside the specified Python installation. You can unset the current version with:

M-x pyenv-mode-unset

Goodies

When you set the Python version with pyenv-mode, the following changes happen automatically:

  • compile commands use proper Python version and environment
  • flycheck performs syntax checking according to Python version you use
  • anaconda-mode search completions, definitions and references respect the chosen environment

Projectile integration

You can switch Python versions together with your current project. Drop the following lines into your Emacs init file. When you use projectile switch project with the C-c p p key binding pyenv-mode will activate the environment matched to the project's name.

(require 'pyenv-mode)

(defun projectile-pyenv-mode-set ()
  "Set pyenv version matching project name."
  (let ((project (projectile-project-name)))
    (if (member project (pyenv-mode-versions))
        (pyenv-mode-set project)
      (pyenv-mode-unset))))

(add-hook 'projectile-after-switch-project-hook 'projectile-pyenv-mode-set)

pyenv-mode's People

Contributors

aarnej avatar celeritascelery avatar cpaulik avatar deybhayden avatar laurencewarne avatar proofit404 avatar syohex avatar wyuenho avatar zuoshifan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.