Git Product home page Git Product logo

pyenv's Introduction

Simple Python Version Management: pyenv

Join the chat at https://gitter.im/yyuu/pyenv

pyenv lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.

This project was forked from rbenv and ruby-build, and modified for Python.

Terminal output example

What pyenv does...

  • Lets you change the global Python version on a per-user basis.
  • Provides support for per-project Python versions.
  • Allows you to override the Python version with an environment variable.
  • Searches for commands from multiple versions of Python at a time. This may be helpful to test across Python versions with tox.

In contrast with pythonbrew and pythonz, pyenv does not...

  • Depend on Python itself. pyenv was made from pure shell scripts. There is no bootstrap problem of Python.
  • Need to be loaded into your shell. Instead, pyenv's shim approach works by adding a directory to your PATH.
  • Manage virtualenv. Of course, you can create virtualenv yourself, or pyenv-virtualenv to automate the process.

Table of Contents


How It Works

At a high level, pyenv intercepts Python commands using shim executables injected into your PATH, determines which Python version has been specified by your application, and passes your commands along to the correct Python installation.

Understanding PATH

When you run a command like python or pip, your operating system searches through a list of directories to find an executable file with that name. This list of directories lives in an environment variable called PATH, with each directory in the list separated by a colon:

/usr/local/bin:/usr/bin:/bin

Directories in PATH are searched from left to right, so a matching executable in a directory at the beginning of the list takes precedence over another one at the end. In this example, the /usr/local/bin directory will be searched first, then /usr/bin, then /bin.

Understanding Shims

pyenv works by inserting a directory of shims at the front of your PATH:

$(pyenv root)/shims:/usr/local/bin:/usr/bin:/bin

Through a process called rehashing, pyenv maintains shims in that directory to match every Python command across every installed version of Python—python, pip, and so on.

Shims are lightweight executables that simply pass your command along to pyenv. So with pyenv installed, when you run, say, pip, your operating system will do the following:

  • Search your PATH for an executable file named pip
  • Find the pyenv shim named pip at the beginning of your PATH
  • Run the shim named pip, which in turn passes the command along to pyenv

Understanding Python version selection

When you execute a shim, pyenv determines which Python version to use by reading it from the following sources, in this order:

  1. The PYENV_VERSION environment variable (if specified). You can use the pyenv shell command to set this environment variable in your current shell session.

  2. The application-specific .python-version file in the current directory (if present). You can modify the current directory's .python-version file with the pyenv local command.

  3. The first .python-version file found (if any) by searching each parent directory, until reaching the root of your filesystem.

  4. The global $(pyenv root)/version file. You can modify this file using the pyenv global command. If the global version file is not present, pyenv assumes you want to use the "system" Python (see below).

A special version name "system" means to use whatever Python is found on PATH after the shims PATH entry (in other words, whatever would be run if Pyenv shims weren't on PATH). Note that Pyenv considers those installations outside its control and does not attempt to inspect or distinguish them in any way. So e.g. if you are on MacOS and have OS-bundled Python 3.8.9 and Homebrew-installed Python 3.9.12 and 3.10.2 -- for Pyenv, this is still a single "system" version, and whichever of those is first on PATH under the executable name you specified will be run.

NOTE: You can activate multiple versions at the same time, including multiple versions of Python2 or Python3 simultaneously. This allows for parallel usage of Python2 and Python3, and is required with tools like tox. For example, to instruct Pyenv to first use your system Python and Python3 (which are e.g. 2.7.9 and 3.4.2) but also have Python 3.3.6, 3.2.1, and 2.5.2 available, you first pyenv install the missing versions, then set pyenv global system 3.3.6 3.2.1 2.5.2. Then you'll be able to invoke any of those versions with an appropriate pythonX or pythonX.Y name. You can also specify multiple versions in a .python-version file by hand, separated by newlines. Lines starting with a # are ignored.

pyenv which <command> displays which real executable would be run when you invoke <command> via a shim. E.g. if you have 3.3.6, 3.2.1 and 2.5.2 installed of which 3.3.6 and 2.5.2 are selected and your system Python is 3.2.5, pyenv which python2.5 should display $(pyenv root)/versions/2.5.2/bin/python2.5, pyenv which python3 -- $(pyenv root)/versions/3.3.6/bin/python3 and pyenv which python3.2 -- path to your system Python due to the fall-through (see below).

Shims also fall through to anything further on PATH if the corresponding executable is not present in any of the selected Python installations. This allows you to use any programs installed elsewhere on the system as long as they are not shadowed by a selected Python installation.

Locating Pyenv-provided Python installations

Once pyenv has determined which version of Python your application has specified, it passes the command along to the corresponding Python installation.

Each Python version is installed into its own directory under $(pyenv root)/versions.

For example, you might have these versions installed:

  • $(pyenv root)/versions/2.7.8/
  • $(pyenv root)/versions/3.4.2/
  • $(pyenv root)/versions/pypy-2.4.0/

As far as Pyenv is concerned, version names are simply directories under $(pyenv root)/versions.


Installation

Getting Pyenv

UNIX/MacOS

Homebrew in macOS
  1. Consider installing with Homebrew:

    brew update
    brew install pyenv

    If you want to install (and update to) the latest development head of Pyenv rather than the latest release, instead run:

    brew install pyenv --head
  2. Then follow the rest of the post-installation steps, starting with Set up your shell environment for Pyenv.

  3. OPTIONAL. To fix brew doctor's warning ""config" scripts exist outside your system or Homebrew directories"

    If you're going to build Homebrew formulae from source that link against Python like Tkinter or NumPy (This is only generally the case if you are a developer of such a formula, or if you have an EOL version of MacOS for which prebuilt bottles are no longer provided and you are using such a formula).

    To avoid them accidentally linking against a Pyenv-provided Python, add the following line into your interactive shell's configuration:

    • Bash/Zsh:

      alias brew='env PATH="${PATH//$(pyenv root)\/shims:/}" brew'
    • Fish:

      alias brew="env PATH=(string replace (pyenv root)/shims '' \"\$PATH\") brew"
Automatic installer
curl https://pyenv.run | bash

For more details visit our other project: https://github.com/pyenv/pyenv-installer

Basic GitHub Checkout

This will get you going with the latest version of Pyenv and make it easy to fork and contribute any changes back upstream.

  • Check out Pyenv where you want it installed. A good place to choose is $HOME/.pyenv (but you can install it somewhere else):
    git clone https://github.com/pyenv/pyenv.git ~/.pyenv
    
  • Optionally, try to compile a dynamic Bash extension to speed up Pyenv. Don't worry if it fails; Pyenv will still work normally:
    cd ~/.pyenv && src/configure && make -C src
    

Windows

Pyenv does not officially support Windows and does not work in Windows outside the Windows Subsystem for Linux. Moreover, even there, the Pythons it installs are not native Windows versions but rather Linux versions running in a virtual machine -- so you won't get Windows-specific functionality.

If you're in Windows, we recommend using @kirankotari's pyenv-win fork -- which does install native Windows Python versions.

Set up your shell environment for Pyenv

Upgrade note: The startup logic and instructions have been updated for simplicity in 2.3.0. The previous, more complicated configuration scheme for 2.0.0-2.2.5 still works.

  • Define environment variable PYENV_ROOT to point to the path where Pyenv will store its data. $HOME/.pyenv is the default. If you installed Pyenv via Git checkout, we recommend to set it to the same location as where you cloned it.
  • Add the pyenv executable to your PATH if it's not already there
  • run eval "$(pyenv init -)" to install pyenv into your shell as a shell function, enable shims and autocompletion
    • You may run eval "$(pyenv init --path)" instead to just enable shims, without shell integration

The below setup should work for the vast majority of users for common use cases. See Advanced configuration for details and more configuration options.

  • For bash:

    Stock Bash startup files vary widely between distributions in which of them source which, under what circumstances, in what order and what additional configuration they perform. As such, the most reliable way to get Pyenv in all environments is to append Pyenv configuration commands to both .bashrc (for interactive shells) and the profile file that Bash would use (for login shells).

    First, add the commands to ~/.bashrc by running the following in your terminal:

    echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
    echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
    echo 'eval "$(pyenv init -)"' >> ~/.bashrc

    Then, if you have ~/.profile, ~/.bash_profile or ~/.bash_login, add the commands there as well. If you have none of these, add them to ~/.profile.

    • to add to ~/.profile:

      echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
      echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
      echo 'eval "$(pyenv init -)"' >> ~/.profile
    • to add to ~/.bash_profile:

      echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
      echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
      echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
  • For Zsh:

    echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
    echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
    echo 'eval "$(pyenv init -)"' >> ~/.zshrc

    If you wish to get Pyenv in noninteractive login shells as well, also add the commands to ~/.zprofile or ~/.zlogin.

  • For Fish shell:

    If you have Fish 3.2.0 or newer, execute this interactively:

    set -Ux PYENV_ROOT $HOME/.pyenv
    fish_add_path $PYENV_ROOT/bin

    Otherwise, execute the snippet below:

    set -Ux PYENV_ROOT $HOME/.pyenv
    set -U fish_user_paths $PYENV_ROOT/bin $fish_user_paths

    Now, add this to ~/.config/fish/config.fish:

    pyenv init - | source

Bash warning: There are some systems where the BASH_ENV variable is configured to point to .bashrc. On such systems, you should almost certainly put the eval "$(pyenv init -)" line into .bash_profile, and not into .bashrc. Otherwise, you may observe strange behaviour, such as pyenv getting into an infinite loop. See #264 for details.

Proxy note: If you use a proxy, export http_proxy and https_proxy, too.

In MacOS, you might also want to install Fig which provides alternative shell completions for many command line tools with an IDE-like popup interface in the terminal window. (Note that their completions are independent from Pyenv's codebase so they might be slightly out of sync for bleeding-edge interface changes.)

Restart your shell

for the PATH changes to take effect.

exec "$SHELL"

Install Python build dependencies

Install Python build dependencies before attempting to install a new Python version.

You can now begin using Pyenv.


Usage

Install additional Python versions

To install additional Python versions, use pyenv install.

For example, to download and install Python 3.10.4, run:

pyenv install 3.10.4

Running pyenv install -l gives the list of all available versions.

NOTE: Most Pyenv-provided Python releases are source releases and are built from source as part of installation (that's why you need Python build dependencies preinstalled). You can pass options to Python's configure and compiler flags to customize the build, see Special environment variables in Python-Build's README for details.

NOTE: If you are having trouble installing a Python version, please visit the wiki page about Common Build Problems.

NOTE: If you want to use proxy for download, please set the http_proxy and https_proxy environment variables.

NOTE: If you'd like a faster interpreter at the cost of longer build times, see Building for maximum performance in Python-Build's README.

Prefix auto-resolution to the latest version

All Pyenv subcommands except uninstall automatically resolve full prefixes to the latest version in the corresponding version line.

pyenv install picks the latest known version, while other subcommands pick the latest installed version.

E.g. to install and then switch to the latest 3.10 release:

pyenv install 3.10
pyenv global 3.10

You can run pyenv latest -k <prefix> to see how pyenv install would resolve a specific prefix, or pyenv latest <prefix> to see how other subcommands would resolve it.

See the pyenv latest documentation for details.

Python versions with extended support

For the following Python releases, Pyenv applies user-provided patches that add support for some newer environments. Though we don't actively maintain those patches, since existing releases never change, it's safe to assume that they will continue working until there are further incompatible changes in a later version of those environments.

  • 3.7.8-3.7.15, 3.8.4-3.8.12, 3.9.0-3.9.7 : XCode 13.3
  • 3.5.10, 3.6.15 : MacOS 11+ and XCode 13.3
  • 2.7.18 : MacOS 10.15+ and Apple Silicon

Switch between Python versions

To select a Pyenv-installed Python as the version to use, run one of the following commands:

E.g. to select the above-mentioned newly-installed Python 3.10.4 as your preferred version to use:

pyenv global 3.10.4

Now whenever you invoke python, pip etc., an executable from the Pyenv-provided 3.10.4 installation will be run instead of the system Python.

Using "system" as a version name would reset the selection to your system-provided Python.

See Understanding shims and Understanding Python version selection for more details on how the selection works and more information on its usage.

Uninstall Python versions

As time goes on, you will accumulate Python versions in your $(pyenv root)/versions directory.

To remove old Python versions, use pyenv uninstall <versions>.

Alternatively, you can simply rm -rf the directory of the version you want to remove. You can find the directory of a particular Python version with the pyenv prefix command, e.g. pyenv prefix 2.6.8. Note however that plugins may run additional operations on uninstall which you would need to do by hand as well. E.g. Pyenv-Virtualenv also removes any virtual environments linked to the version being uninstalled.

Other operations

Run pyenv commands to get a list of all available subcommands. Run a subcommand with --help to get help on it, or see the Commands Reference.

Note that Pyenv plugins that you install may add their own subcommands.

Upgrading

Upgrading with Homebrew

If you've installed Pyenv using Homebrew, upgrade using:

brew upgrade pyenv

To switch from a release to the latest development head of Pyenv, use:

brew uninstall pyenv
brew install pyenv --head

then you can upgrade it with brew upgrade pyenv as usual.

Upgrading with Installer or Git checkout

If you've installed Pyenv with Pyenv-installer, you likely have the Pyenv-Update plugin that would upgrade Pyenv and all installed plugins:

pyenv update

If you've installed Pyenv using Pyenv-installer or Git checkout, you can also upgrade your installation at any time using Git.

To upgrade to the latest development version of pyenv, use git pull:

cd $(pyenv root)
git pull

To upgrade to a specific release of Pyenv, check out the corresponding tag:

cd $(pyenv root)
git fetch
git tag
git checkout v0.1.0

Uninstalling pyenv

The simplicity of pyenv makes it easy to temporarily disable it, or uninstall from the system.

  1. To disable Pyenv managing your Python versions, simply remove the pyenv init invocations from your shell startup configuration. This will remove Pyenv shims directory from PATH, and future invocations like python will execute the system Python version, as it was before Pyenv.

    pyenv will still be accessible on the command line, but your Python apps won't be affected by version switching.

  2. To completely uninstall Pyenv, remove all Pyenv configuration lines from your shell startup configuration, and then remove its root directory. This will delete all Python versions that were installed under the $(pyenv root)/versions/ directory:

    rm -rf $(pyenv root)

    If you've installed Pyenv using a package manager, as a final step, perform the Pyenv package removal. For instance, for Homebrew:

    brew uninstall pyenv
    

Pyenv plugins

Pyenv provides a simple, flexible and maintainable way to extend and customize its functionality with plugins -- as simple as creating a plugin directory and dropping a shell script on a certain subpath of it with whatever extra logic you need to be run at certain moments.

See Plugins on the wiki on how to install and use plugins as well as a catalog of some useful existing plugins for common needs.

See Authoring plugins on the wiki on writing your own plugins.

Advanced Configuration

Skip this section unless you must know what every line in your shell profile is doing.

Also see the Environment variables section for the environment variables that control Pyenv's behavior.

pyenv init is the only command that crosses the line of loading extra commands into your shell. Coming from RVM, some of you might be opposed to this idea. Here's what eval "$(pyenv init -)" actually does:

  1. Sets up the shims path. This is what allows Pyenv to intercept and redirect invocations of python, pip etc. transparently. It prepends $(pyenv root)/shims to your $PATH. It also deletes any other instances of $(pyenv root)/shims on PATH which allows to invoke eval "$(pyenv init -)" multiple times without getting duplicate PATH entries.

  2. Installs autocompletion. This is entirely optional but pretty useful. Sourcing $(pyenv root)/completions/pyenv.bash will set that up. There are also completions for Zsh and Fish.

  3. Rehashes shims. From time to time you'll need to rebuild your shim files. Doing this on init makes sure everything is up to date. You can always run pyenv rehash manually.

  4. Installs pyenv into the current shell as a shell function. This bit is also optional, but allows pyenv and plugins to change variables in your current shell. This is required for some commands like pyenv shell to work. The sh dispatcher doesn't do anything crazy like override cd or hack your shell prompt, but if for some reason you need pyenv to be a real script rather than a shell function, you can safely skip it.

eval "$(pyenv init --path)" only does items 1 and 3.

To see exactly what happens under the hood for yourself, run pyenv init - or pyenv init --path.

eval "$(pyenv init -)" is supposed to run at any interactive shell's startup (including nested shells -- e.g. those invoked from editors) so that you get completion and convenience shell functions.

eval "$(pyenv init --path)" can be used instead of eval "$(pyenv init -)" to just enable shims, without shell integration. It can also be used to bump shims to the front of PATH after some other logic has prepended stuff to PATH that may shadow Pyenv's shims.

  • In particular, in Debian-based distributions, the stock ~/.profile prepends per-user bin directories to PATH after having sourced ~/.bashrc. This necessitates appending a pyenv init call to ~/.profile as well as ~/.bashrc in these distributions because the system's Pip places executables for modules installed by a non-root user into those per-user bin directories.

Using Pyenv without shims

If you don't want to use pyenv init and shims, you can still benefit from pyenv's ability to install Python versions for you. Just run pyenv install and you will find versions installed in $(pyenv root)/versions.

You can manually execute or symlink them as required, or you can use pyenv exec <command> whenever you want <command> to be affected by Pyenv's version selection as currently configured.

pyenv exec works by prepending $(pyenv root)/versions/<selected version>/bin to PATH in the <command>'s environment, the same as what e.g. RVM does.

Environment variables

You can affect how Pyenv operates with the following environment variables:

name default description
PYENV_VERSION Specifies the Python version to be used.
Also see pyenv shell
PYENV_ROOT ~/.pyenv Defines the directory under which Python versions and shims reside.
Also see pyenv root
PYENV_DEBUG Outputs debug information.
Also as: pyenv --debug <subcommand>
PYENV_HOOK_PATH see wiki Colon-separated list of paths searched for pyenv hooks.
PYENV_DIR $PWD Directory to start searching for .python-version files.
PYTHON_BUILD_ARIA2_OPTS Used to pass additional parameters to aria2.
If the aria2c binary is available on PATH, pyenv uses aria2c instead of curl or wget to download the Python Source code. If you have an unstable internet connection, you can use this variable to instruct aria2 to accelerate the download.
In most cases, you will only need to use -x 10 -k 1M as value to PYTHON_BUILD_ARIA2_OPTS environment variable

See also Special environment variables in Python-Build's README for environment variables that can be used to customize the build.


Development

The pyenv source code is hosted on GitHub. It's clean, modular, and easy to understand, even if you're not a shell hacker.

Tests are executed using Bats:

bats test
bats/test/<file>.bats

Contributing

Feel free to submit pull requests and file bugs on the issue tracker.

See CONTRIBUTING.md for more details on submitting changes.

Version History

See CHANGELOG.md.

License

The MIT License

pyenv's People

Contributors

8dhn avatar anton-petrov avatar aphedges avatar banzaiman avatar blueyed avatar cclauss avatar chrahunt avatar clbarnes avatar edgarrmondragon avatar felicianotech avatar fredrikaverpil avatar gotche avatar guilleiguaran avatar jasonkarns avatar joesiewert avatar josh avatar joshfriend avatar mislav avatar msimacek avatar native-api avatar nedbat avatar proinsias avatar saaketp avatar samureus avatar sandipanpanda avatar scop avatar shoichiaizawa avatar sstephenson avatar yyuu avatar zmwangx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyenv's Issues

Build failed Xubuntu 13.04

Given a freshly installed Xubuntu 13.04 64-bit Virtualbox Guest, I also experience the following issue: #40

However, no matter which flavour of libreadline-dev I install onto the system, pyenv can't build the python readline extension.

Downloading Python-2.6.8.tgz...
-> http://yyuu.github.io/pythons/f6c1781f5d73ab7dfa5181f43ea065f6
Installing Python-2.6.8...

BUILD FAILED

Inspect or clean up the working tree at /tmp/python-build.20130812163804.11579
Results logged to /tmp/python-build.20130812163804.11579.log

Last 10 log lines:
(cd /home/victor/.pyenv/versions/2.6.8/bin; ln python2.6 python)
rm -f /home/victor/.pyenv/versions/2.6.8/bin/python-config
(cd /home/victor/.pyenv/versions/2.6.8/bin; ln -s python2.6-config python-config)
Creating directory /home/victor/.pyenv/versions/2.6.8/share/man
Creating directory /home/victor/.pyenv/versions/2.6.8/share/man/man1
/usr/bin/install -c -m 644 ./Misc/python.man \
                /home/victor/.pyenv/versions/2.6.8/share/man/man1/python.1
Traceback (most recent call last):
  File "<string>", line 4, in <module>
ImportError: The Python readline extension was not compiled. Missing the GNU readline lib?

How to point to local python

I got a script that asks to set where to find python. If I already have a local version set with all of my libraries installed, how to tell my script where to find that executable python?

P.S. my script runs on a different directory than where I have set the local python.

Build failed on ubuntu 13.04

pythonenv install 2.7.5

throws an error:

Traceback (most recent call last):
File "", line 4, in
ImportError: The Python ssl extension was not compiled. Missing the OpenSSL lib?

I have the openssl, python-openssl and python-openssl-debug libraries installed in ubuntu 13.04.

For python 3.x pip installs ipython3 that is not 3 complainant.

I successfully installed pythons 3.2.5 and 3.3.2 using pyenv but after installing ipython with pip ipython3 calls application.py from the 3.3.2 directory and an error occurs.

The reported syntax error appears to be a problem with the print function and not using ().

Any ideas how to remedy this? I'm not sure where to start.

Thanks
Gene

Ceti$ pe3
  system
  2.6.8
  2.7.5
  3.2.5
* 3.3.2 (set by PYENV_VERSION environment variable)
Ceti$ ipython3
Traceback (most recent call last):
  File "/usr/local/opt/pyenv/versions/3.3.2/bin/ipython3", line 9, in <module>
    load_entry_point('ipython==0.13.2', 'console_scripts', 'ipython3')()
  File "/usr/local/opt/pyenv/versions/3.3.2/lib/python3.3/site-packages/setuptools-0.7.2-py3.3.egg/pkg_resources.py", line 347, in load_entry_point
  File "/usr/local/opt/pyenv/versions/3.3.2/lib/python3.3/site-packages/setuptools-0.7.2-py3.3.egg/pkg_resources.py", line 2518, in load_entry_point
  File "/usr/local/opt/pyenv/versions/3.3.2/lib/python3.3/site-packages/setuptools-0.7.2-py3.3.egg/pkg_resources.py", line 2212, in load
  File "/usr/local/opt/pyenv/versions/3.3.2/lib/python3.3/site-packages/IPython/__init__.py", line 43, in <module>
    from .config.loader import Config
  File "/usr/local/opt/pyenv/versions/3.3.2/lib/python3.3/site-packages/IPython/config/__init__.py", line 16, in <module>
    from .application import *
  File "/usr/local/opt/pyenv/versions/3.3.2/lib/python3.3/site-packages/IPython/config/application.py", line 242
    print os.linesep.join(lines)
           ^
SyntaxError: invalid syntax

Add deactivation

Is there no deactivation of pyenv? there is pyenv init commands, but sometimes I want to use original python (because homebrew requires brewed python sometimes).

Error with libffi while installing Python 2.7.5 on Cygwin 64

Hi,

first thanks for developing and maintaining pyenv, a great tool I've successfully used on Linux. :)

Now I'd like to use it to setup a Python environment on Windows (7 if it matters).
So I'm using Cygwin to get a similar experience to Linux, and I've managed to setup all the tools necessary for installing pyenv and running the install of the 2.7.5.

But seems like this configuration has not been taken into account by the libffi used by ctypes because when running a simple:

pyenv install --verbose 2.7.5

I get this error:

BUILD FAILED

Inspect or clean up the working tree at /tmp/python-build.20130925011146.6068
Results logged to /tmp/python-build.20130925011146.6068.log

Last 10 log lines:
    self.build_extension(ext)
  File "./setup.py", line 285, in build_extension
    if not self.configure_ctypes(ext):
  File "./setup.py", line 1988, in configure_ctypes
    exec f in fficonfig
  File "build/temp.cygwin-1.7.25-x86_64-2.7/libffi/fficonfig.py", line 33, in <module>
    ffi_sources += ffi_platforms['X86_WIN64']
KeyError: 'X86_WIN64'
Makefile:471: recipe for target `sharedmods' failed
make: *** [sharedmods] Error 1

And indeed in the table that maps the platform to the source files there is no X86_WIN64 entry.

Have you already seen this issue?
Have you any idea to solve it or should I contact the libffi guys directly?

I fear there is no solution but just in case... :)

Thanks for any help.

History subsitution doesn't work with pyenv

When using python through pyenv, the history subsitution (hitting up arrow to view previous commands) doesn't work. I'm on zsh on mac os x. I've seen similar behaviour in python that is run from a batch file in zsh on cygwin. Think it's something to do with it being wrapped, but I have no idea how to fix it.

Build faild for ssl error of curl, when fetching old version

When I install 2.6.6, SSL error occurred. The error message is below.

$ pyenv install 2.6.6
Downloading http://www.python.org/ftp/python/2.6.6/Python-2.6.6.tgz...

curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). The default
 bundle is named curl-ca-bundle.crt; you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use  the -k (or --insecure) option.

BUILD FAILED

If ALL curl session is allowed not to use ssl, ".pyenv/plugins/python-build/bin/python-build:L133" would be modified below, but it is not smart...

<<< curl -L "$@"
>>> curl -L --insecure "$@"

failed to compile py2cairo when using pyenv

When I try to compile py2cairo-1.10.0:

./waf configure
./options()
Setting top to : /home/nitro/src/py2cairo-1.10.0
Setting out to : /home/nitro/src/py2cairo-1.10.0/build_directory
./configure()
Checking for 'gcc' (c compiler) : ok
Checking for program python : /home/nitro/.pyenv/shims/python
Checking for python version : (2, 7, 3, 'final', 0)
Checking for library python2.7 : yes
Checking for program python2.7-config : /home/nitro/.pyenv/shims/python2.7-config
command ['/home/nitro/.pyenv/shims/python', '/home/nitro/.pyenv/shims/python2.7-config', '--includes'] returned 1

And I try to compile an old version pycairo 1.8.10, I got another error:

./waf configure
./set_options
./init
./configure
Checking for program gcc or cc : /usr/bin/gcc
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for gcc : ok
Checking for program python : /home/nitro/.pyenv/shims/python
Checking for Python version >= 2.6.0 : ok 2.7.3
Checking for library python2.7 : yes
Checking for program python2.7-config : /home/nitro/.pyenv/shims/python2.7-config
File "/home/nitro/.pyenv/shims/python2.7-config", line 3
[ -n "$PYENV_DEBUG" ] && set -x
^
SyntaxError: invalid syntax
Traceback (most recent call last):
File "./waf", line 158, in
Scripting.prepare(t, cwd, VERSION, wafdir)
File "/home/nitro/src/pycairo-1.8.10/.waf-1.5.16-264215ab3a9d1657aa677dbfa7c8e3f2/wafadmin/Scripting.py", line 105, in prepare
prepare_impl(t,cwd,ver,wafdir)
File "/home/nitro/src/pycairo-1.8.10/.waf-1.5.16-264215ab3a9d1657aa677dbfa7c8e3f2/wafadmin/Scripting.py", line 98, in prepare_impl
main()
File "/home/nitro/src/pycairo-1.8.10/.waf-1.5.16-264215ab3a9d1657aa677dbfa7c8e3f2/wafadmin/Scripting.py", line 133, in main
fun(ctx)
File "/home/nitro/src/pycairo-1.8.10/.waf-1.5.16-264215ab3a9d1657aa677dbfa7c8e3f2/wafadmin/Scripting.py", line 172, in configure
conf.sub_config([''])
File "/home/nitro/src/pycairo-1.8.10/.waf-1.5.16-264215ab3a9d1657aa677dbfa7c8e3f2/wafadmin/Configure.py", line 140, in sub_config
self.recurse(k,name='configure')
File "/home/nitro/src/pycairo-1.8.10/.waf-1.5.16-264215ab3a9d1657aa677dbfa7c8e3f2/wafadmin/Utils.py", line 461, in recurse
f(self)
File "/home/nitro/src/pycairo-1.8.10/wscript", line 32, in configure
conf.check_python_headers()
File "/home/nitro/src/pycairo-1.8.10/.waf-1.5.16-264215ab3a9d1657aa677dbfa7c8e3f2/wafadmin/Tools/python.py", line 184, in check_python_headers
for incstr in Utils.cmd_output("%s %s --includes"%(python,python_config)).strip().split():
File "/home/nitro/src/pycairo-1.8.10/.waf-1.5.16-264215ab3a9d1657aa677dbfa7c8e3f2/wafadmin/Utils.py", line 337, in cmd_output
raise ValueError(msg)
ValueError: command execution failed: /home/nitro/.pyenv/shims/python /home/nitro/.pyenv/shims/python2.7-config --includes -> ''

waf configure succeed when I do them without pyenv enabled, the python version are the same, namely my system python installation 2.7.

I've also tried with a python installed by pyenv, it runs into another problem:

./waf configure
./options()
Setting top to : /home/nitro/src/py2cairo-1.10.0
Setting out to : /home/nitro/src/py2cairo-1.10.0/build_directory
./configure()
Checking for 'gcc' (c compiler) : ok
Checking for program python : /home/nitro/.pyenv/versions/2.7.4/bin/python
Checking for python version : (2, 7, 4, 'final', 0)
Traceback (most recent call last):
File "/home/nitro/src/py2cairo-1.10.0/.waf-1.6.3-3c3129a3ec8fb4a5bbc7ba3161463b22/waflib/Scripting.py", line 93, in waf_entry_point
run_commands()
File "/home/nitro/src/py2cairo-1.10.0/.waf-1.6.3-3c3129a3ec8fb4a5bbc7ba3161463b22/waflib/Scripting.py", line 145, in run_commands
run_command(cmd_name)
File "/home/nitro/src/py2cairo-1.10.0/.waf-1.6.3-3c3129a3ec8fb4a5bbc7ba3161463b22/waflib/Scripting.py", line 138, in run_command
ctx.execute()
File "/home/nitro/src/py2cairo-1.10.0/.waf-1.6.3-3c3129a3ec8fb4a5bbc7ba3161463b22/waflib/Configure.py", line 124, in execute
super(ConfigurationContext,self).execute()
File "/home/nitro/src/py2cairo-1.10.0/.waf-1.6.3-3c3129a3ec8fb4a5bbc7ba3161463b22/waflib/Context.py", line 87, in execute
self.recurse([os.path.dirname(g_module.root_path)])
File "/home/nitro/src/py2cairo-1.10.0/.waf-1.6.3-3c3129a3ec8fb4a5bbc7ba3161463b22/waflib/Context.py", line 127, in recurse
user_function(self)
File "/home/nitro/src/py2cairo-1.10.0/wscript", line 29, in configure
ctx.check_python_headers()
File "/home/nitro/src/py2cairo-1.10.0/.waf-1.6.3-3c3129a3ec8fb4a5bbc7ba3161463b22/waflib/Configure.py", line 214, in fun
return f(k,*kw)
File "/home/nitro/src/py2cairo-1.10.0/.waf-1.6.3-3c3129a3ec8fb4a5bbc7ba3161463b22/waflib/Tools/python.py", line 123, in check_python_headers
if dct[x]:
KeyError: 'MACOSX_DEPLOYMENT_TARGET'

I don't where the MACOSX_DEPLOYMENT_TARGET comes from, I'm using Ubuntu Precise.

Won't install python 2.7.4 if /tmp is mounted noexec

The error was...

:~$ pyenv install 2.7.4
Installing Python-2.7.4...

BUILD FAILED

Inspect or clean up the working tree at /tmp/python-build.20130416221217.21910
Results logged to /tmp/python-build.20130416221217.21910.log

Last 10 log lines:
Python-2.7.4/Misc/indent.pro
Python-2.7.4/Misc/ACKS
Python-2.7.4/Misc/README.valgrind
Python-2.7.4/Misc/RPM/
Python-2.7.4/Misc/RPM/README
Python-2.7.4/Misc/RPM/python-2.7.spec
Python-2.7.4/Misc/valgrind-python.supp
Python-2.7.4/Misc/README.klocwork
/tmp/python-build.20130416221217.21910/Python-2.7.4 /tmp/python-build.20130416221217.21910 ~
/home/$USER/.pyenv/plugins/python-build/bin/python-build: line 373: ./configure: Permission denied

This would probably happen for any version. Fixed it by doing...

:~$ sudo mount -o remount,exec /tmp

I'm in ubuntu 12.10 64, though I can't remember if I changed default behaviour of /tmp.

A possible solution could be to check if /tmp is being mounted noexec and ask for an alternative if it is...

Fish shell support

Is the support of fish shell planned? There are some mentions of fish on wiki, but currently pyenv does not work in it.

Namely, the problem is pyenv init, which tries to perform a bash eval inside fish, which, of course, fails. Installation/uninstallation of Python versions seems to work normally.

"... command exists in these Python versions" even if there is only one version.

Unfortunately I have encountered another problem.
I have installed python 2.7.5 with pyenv install 2.7.5 and then pyenv rehash
Now if I type python2.7 I get

pyenv: python2.7: command not found
The `python2.7' command exists in these Python versions:
2.7.5

I think this message should appear if there are others pythonx.y or pythonx version and the command is ambiguous but I have only one python version.
If I set pyenv local 2.7.5 then python2 or python2.7will start python correctly.

Am I missing something? Is possible to set the default pythonx version?

Bug with virtualenvwrapper when sourcing script from shim

virtualenvwrapper has a few .sh scripts you're supposed to source (Either virtualenvwrapper.sh or virtualenvwrapper_lazy.sh).

However the shim uses an exec call to call whichever script we expect. This causes the shell to close as it replaces the current shell and then exits.

Any way to handle this. Perhaps by making the shim detect if its being sourced rather than executed?

SSL issue with pypi while installing python 2.7.3

Hi I'm trying to install python 2.7.3 on an old Centos5.8 machine. On hitting
pyenv install python2.7.3 I get

ERROR: certificate common name *.a.ssl.fastly.net' doesn't match requested host namepypi.python.org'.
To connect to pypi.python.org insecurely, use `--no-check-certificate'.

I believe this is during wget(or any http) call to get setuptools. Can you please help me in providing this as part of command line.

Prepare CDN for faster downloads?

The upstream ruby-build has official download mirror sponsored by 37signals. The mirror is built using CloudFront of AWS.

I'd like to provide equivalent functions to python-build, but I'm afraid if it costs too much.
Is there any way to provide fast mirror with cheaper cost? Use GitHub pages?

add tests

Please add tests for pyenv and python-build.

The upstream project rbenv and ruby-build have implemented tests with using bats.

Jython 2.5.0 and 2.5.1 builds on OSX failing with "No module named posix" when installing distribute

Downloading Jython-2.5.1.jar...
-> https://downloads.sourceforge.net/project/jython/jython/2.5.1/jython_installer-2.5.1.jar
Installing Jython-2.5.1...
Installed Jython-2.5.1 to /Users/justin/.pyenv/versions/jython-2.5.1

Downloading distribute-0.6.36.tar...
-> http://pypi.python.org/packages/source/d/distribute/distribute-0.6.36.tar.gz
Installing distribute-0.6.36...

BUILD FAILED

Inspect or clean up the working tree at /var/folders/lg/g_v4qdsj7y75t2v6d35c4hx00000gq/T/python-build.20130426223201.90008
Results logged to /var/folders/lg/g_v4qdsj7y75t2v6d35c4hx00000gq/T/python-build.20130426223201.90008.log

Last 10 log lines:
    easy_install = self.distribution.get_command_class('easy_install')
  File "/private/var/folders/lg/g_v4qdsj7y75t2v6d35c4hx00000gq/T/python-build.20130426223201.90008/distribute-0.6.36/setuptools/dist.py", line 363, in get_command_class
    self.cmdclass[command] = cmdclass = ep.load()
  File "/private/var/folders/lg/g_v4qdsj7y75t2v6d35c4hx00000gq/T/python-build.20130426223201.90008/distribute-0.6.36/pkg_resources.py", line 2015, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/private/var/folders/lg/g_v4qdsj7y75t2v6d35c4hx00000gq/T/python-build.20130426223201.90008/distribute-0.6.36/setuptools/command/easy_install.py", line 24, in <module>
    from setuptools.sandbox import run_setup
  File "/private/var/folders/lg/g_v4qdsj7y75t2v6d35c4hx00000gq/T/python-build.20130426223201.90008/distribute-0.6.36/setuptools/sandbox.py", line 3, in <module>
    import org.python.modules.posix.PosixModule as _os
ImportError: No module named posix

Problem when downloading 'setuptools-0.7.2.tar.gz'

I always get a curl error when downloading setuptools. And that makes me impossible to finish installing any version of Python.

The Python package and readline are mirrored, which makes the download speed much faster, that's great. But the setuptools is stilled required to be downloaded from other place.

It would be great if the setuptools is also mirrored or there's an option to download it from anywhere else.

Ubuntu - Shell doesn't persist.

I am on Ubuntu precise.

I installed pyenv to bashrc as ubuntu doesn't use bash_profile

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc

I exec $SHELL and pyenv works.
I set global in my case

sayth@sayth-TravelMate-5740G:~$ pyenv versions
system

  • 3.3.2 (set by /home/sayth/.pyenv/version)
    sayth@sayth-TravelMate-5740G:~$ pyenv global 3.3.2

sayth@sayth-TravelMate-5740G:~$ python --version
Python 3.3.2

However if I close the terminal or restart machine pyenv is gone.
pyenv: command not found
sayth@sayth-TravelMate-5740G:~$

Build of python 2.5 failed with subversion on Archlinux

I'm trying to install 2.5.6 and will dont work.
Maybe has to do with this http://superuser.com/questions/564118/error-compiling-python-2-7-3-on-centos5

tim@localhost ~ % pyenv install 2.5.6
Downloading Python-2.5.6.tar...
-> http://www.python.org/ftp/python/2.5.6/Python-2.5.6.tgz
Installing Python-2.5.6...

BUILD FAILED

Inspect or clean up the working tree at /tmp/python-build.20130422153800.5017
Results logged to /tmp/python-build.20130422153800.5017.log

Last 10 log lines:
Parser/pgen ./Grammar/Grammar ./Include/graminit.h ./Python/graminit.c
mkdir: cannot create directory ‘Include’: File exists
make: [Python/graminit.c] Error 1 (ignored)
Parser/pgen ./Grammar/Grammar ./Include/graminit.h ./Python/graminit.c
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -I'/home/tim/.pyenv/versions/2.5.6/include' -DPy_BUILD_CORE -o Python/compile.o Python/compile.c
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -I'/home/tim/.pyenv/versions/2.5.6/include' -DPy_BUILD_CORE -o Python/graminit.o Python/graminit.c
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -I'/home/tim/.pyenv/versions/2.5.6/include' -DPy_BUILD_CORE -o Python/symtable.o Python/symtable.c
gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -I'/home/tim/.pyenv/versions/2.5.6/include' -DPy_BUILD_CORE -DSVNVERSION="LC_ALL=C svnversion ." -o Modules/getbuildinfo.o ./Modules/getbuildinfo.c
gcc: error: directory": No such file or directory
make: *** [Modules/getbuildinfo.o] Error 1

Do you have any ideas?

Installing Python 2.5.6 (and 2.5.4) fails on OS X 10.8

Update: the log bits are from 2.5.4. The build log for 2.5.6 can be found https://gist.github.com/al3xandru/6018589

Some parts of the log:

Beginning configuration for readline-6.2 for i386-apple-darwin12.4.1
…
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
i686-apple-darwin11-llvm-gcc-4.2: -compatibility_version only allowed with -dynamiclib
make[1]: *** [libhistory.6.2.dylib] Error 1
make[1]: *** Waiting for unfinished jobs....
mv compat.o compat.so
make: [shared] Error 2 (ignored)
…
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
i686-apple-darwin11-llvm-gcc-4.2: -compatibility_version only allowed with -dynamiclib
make[1]: *** [libreadline.6.2.dylib] Error 1
make: [shared] Error 2 (ignored)
( cd examples ; make  DESTDIR= install )
…
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
i686-apple-darwin11-llvm-gcc-4.2: -compatibility_version only allowed with -dynamiclib
make[1]: *** [libreadline.6.2.dylib] Error 1
make: [install-shared] Error 2 (ignored)

and then:

checking for c++... c++
configure: WARNING:

  By default, distutils will build C++ extension modules with "c++".
  If this is not intended, then set CXX on the configure command line.

checking how to run the C preprocessor... /usr/bin/gcc -E

and

/usr/bin/gcc -c -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include -I'/Users/apopescu/.pyenv/versions/2.5.4/include'   -DPy_BUILD_CORE -o Modules/_typesmodule.o Modules/_typesmodule.c
cc1: error: unrecognized command line option "-Wno-long-double"^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
^@make: *** [Modules/_typesmodule.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [Modules/python.o] Error 1

Complete build log https://gist.github.com/al3xandru/6018330

Cannot build 2.6.x on openSUSE 12.3

Hello, I'm using latest version of pyenv from git to build python 2.6.8 on my openSUSE 12.3 x86_64 machine.

This is the output produced by pyenv install 2.6.8.

Please notice that:

  • lib readline development headers are installed on my system.
  • ncurses development headers are installed as well.
  • if I enter the build root I can start the python binary without any issue (and I can also load the readline module).

brew doctor reports warnings after installing pyenv.

After installing pyenv using the Homebrew, brew doctor reports warning.

$ brew doctor
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:

    /Users/maaru/.pyenv/shims/python-config
    /Users/maaru/.pyenv/shims/python2-config
    /Users/maaru/.pyenv/shims/python2.7-config

Is this a normal situation?

Compare hashes to avoid re-downloading.

This is just a suggestion.
Why not before downloading, check if the requested version has already been downloaded and compare hashes. This can save some time when build fails due to missing libs.

Installing to a non-standard location

Hello, I have pyenv cloned to a non-standard location (~/.dotfiles/pyenv), and this causes pyenv init - to return confused paths.

export PATH="/home/ehealy/.pyenv/shims:${PATH}"
source "/home/ehealy/.dotfiles/pyenv/libexec/../completions/pyenv.zsh"
pyenv rehash 2>/dev/null
pyenv() {
  typeset command
  command="$1"
  if [ "$#" -gt 0 ]; then
    shift
  fi

  case "$command" in
  rehash|shell)
    eval `pyenv "sh-$command" "$@"`;;
  *)
    command pyenv "$command" "$@";;
  esac
}

I'm using oh-my-zsh to configure zsh. Here is the segment I've added to my .zshenv file:

# Set up pyenv.
export PATH="$HOME/.dotfiles/pyenv/bin:$PATH"
eval "$(pyenv init -)"

This results in strangeness like the install command not being available in pyenv:

pyenv 0.4.0-20130613
Usage: pyenv <command> [<args>]

Some useful pyenv commands are:
   commands    List all available pyenv commands
   local       Set or show the local application-specific Python version
   global      Set or show the global Python version
   shell       Set or show the shell-specific Python version
   rehash      Rehash pyenv shims (run this after installing executables)
   version     Show the current Python version and its origin
   versions    List all Python versions available to pyenv
   which       Display the full path to an executable
   whence      List all Python versions that contain the given executable

See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/yyuu/pyenv#readme

Warning when installing new python

I installed a new python with the command rbenv install 2.7.5 and at the first line I got this:

/home/ans/.pyenv/plugins/python-build/bin/python-build: line 642: break: only meaningful in a `for', `while', or `until' loop

penv using homebrew pythons

Is there a way to include pythons installed through Homebrew (OSX) to pyenv versions?

It could be great since using Homebrew is a lot more easy to install libraries like PyQt or Scipy.

I guess that somehow pyenv should know that the python binary is in /usr/local/share/python and libraries in /usr/local/lib/python2.7/site-packages (for the default python 2.7.3 at least).

Sorry if it has a trivial solution. I am still starting with Python.

[Question] is pyenv can built for every ubuntu version?

I think using pyenv to create a individual and separated folder.
Then, I can tar ~/.pyenv to different ubuntu versions, say 10.10, 11.04, 13.04?

However, today I tried ~/.pyenv that created on ubuntu 13.04
and using it on ubuntu 10.04.

when using urllib, it has some errors cuz
.pyenv/versions/2.6.6/lib/python2.6/lib-dynload/_hashlib.so linked /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 but the file not exist on ubuntu 10.04.

How could I use pyenv to have a full individual environment to run python2.6?
, means can run my script properly on all ubuntu x86_64 platform.

Thanks a lot,
Jay

`pyenv install` subcommand has gone missing

pyenv no longer seems to have an install command. Assuming from the README this was once a part of pyenv as a whole, and a not in a seperate 'py-build' like the rbenv equivalent?

Also, I'd like to add a formula to Homebrew for pyenv, would you be ok with that?

Mint15 installation fails with readline error

I've tried installing both CPython 2.5.6 and 2.7.5 on a fresh Mint15 system. In both cases the pyenv install failed with the following error:

Writing /home/alex/.pyenv/versions/2.5.6/lib/python2.5/lib-dynload/Python-2.5.6-py2.5.egg-info
if test -f /home/alex/.pyenv/versions/2.5.6/bin/python -o -h /home/alex/.pyenv/versions/2.5.6/bin/python; \
        then rm -f /home/alex/.pyenv/versions/2.5.6/bin/python; \
        else true; \
        fi
(cd /home/alex/.pyenv/versions/2.5.6/bin; ln python2.5 python)
rm -f /home/alex/.pyenv/versions/2.5.6/bin/python-config
(cd /home/alex/.pyenv/versions/2.5.6/bin; ln -s python2.5-config python-config)
Creating directory /home/alex/.pyenv/versions/2.5.6/share/man
Creating directory /home/alex/.pyenv/versions/2.5.6/share/man/man1
/usr/bin/install -c -m 644 ./Misc/python.man \
                /home/alex/.pyenv/versions/2.5.6/share/man/man1/python.1
Traceback (most recent call last):
  File "<string>", line 4, in <module>
ImportError: The Python readline extension was not compiled. Missing the GNU readline lib?

According to the package manager, I already have installed libreadline5, libreadline6 and readline-common. Do I miss a package?

Installation to somewhere other than ~/.pyenv

When installing to somewhere other than ~/.pyenv the plugin folder is not visible. Meaning commands like pyenv install 2.7.5 fail with install command not found.

This is due to the default set in line 24 of libexec/pyenv

if [ -z "${PYENV_ROOT}" ]; then
  PYENV_ROOT="${HOME}/.pyenv"
else

My question is can the default be set to something more sensible like...

if [ -z "${PYENV_ROOT}" ]; then
  PYENV_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
else

Installation of a copy of Python failed (Mac OS X 10.8.4)

My system is

  • Mac OS X 10.8.4
  • Homebrew
  • zsh 5.0.2

I installed Python 2.7.5 using precompiled installer from http://www.python.org.

After that, I tried to install Python 3.3.2 using pyenv with --enable-frameworks

export CONFIGURE_OPTS=--enable-framework --enable-toolbox-glue --enable-ipv6 --enable-big-digits --enable-unicode --with-threads
pyenv install 3.3.2

But failed and I got these messages:

Creating directory /Library/Frameworks/Python.framework/Versions/3.3/Resources/English.lproj
install: mkdir /Library/Frameworks/Python.framework/Versions/3.3: Permission denied
Creating directory /Library/Frameworks/Python.framework/Versions/3.3/lib
install: mkdir /Library/Frameworks/Python.framework/Versions/3.3: Permission denied
make: *** [frameworkinstallstructure] Error 71

I think the files are expected to be installed in $PYENV_ROOT/versions.

When I tried with Python 2.7.5, I got the same result.

I also tried with --prefix=$HOME/.pyenv/versions
But I got nothing.

Thanks.

Permission denied

I installed pyenv successfully using homebrew, but when I tried to install a python, I got a whole bunch of errors, but looking at the logs only one error stood out: Permission denied.

I think it's because on OS X the default install dir is set to /lib/python2.7/site-packages/...

So how do I change the install dir of new pythons and what do I change it to please?

Build failed on Xubuntu 12.10

Hi,

pyenv install 2.7.5
Downloading Python-2.7.5.tgz...
-> http://yyuu.github.io/pythons/b4f01a1d0ba0b46b05c73b2ac909b1df
Installing Python-2.7.5...

BUILD FAILED
....
....
Traceback (most recent call last):
File "", line 4, in
ImportError: The Python bz2 extension was not compiled. Missing the bzip2 lib?

My system:
Linux xbnt 3.5.0-37-generic #58-Ubuntu SMP Mon Jul 8 22:07:55 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Packages:
dpkg --get-selections | grep bzip
bzip2
libzip2

Create Wiki

Create Wiki pages for pyenv project.
Wiki pages might be useful since it can be edited by someone who doesn't have commit privileges.

  • fork and modify the wiki of rbenv.
  • gather workarounds for well-known build problems

~/.pyenv/version and .python-version don't work

Hi,

I used to using pythonbrew, but recently found that was deprecated and recommending use pyenv. So I tried.

I'm using pyenv on Gentoo Linux with bash, and pyenv v0.4.0-20130726.

pyenv global 2.7.5 and pyenv local 2.7.5 didn't work for me.

$ pyenv global 2.7.5
$ pyenv global 
2.7.5
$ command -v python
/usr/bin/python
$ pyenv which python
/home/nobody/.pyenv/versions/2.7.5/bin/python
$ pyenv exec python -c 'import sys; print sys.path[1]'
/home/nobody/.pyenv/versions/2.7.5/lib/python2.7/site-packages/setuptools-0.9.7-py2.7.egg

When i cd to a directory with .python-version file, nothing happend.

The only choice is use pyenv exec ...

My .bash_profile

# some personal setting stuff
export PATH="$HOME/.pyenv/bin:$PATH"

Any idea?

Thanks.

Python 2.7.5 doesn't compile on OS X (10.7 and 10.8) because of missing readline

OS X has a faux-readline library that doesn't quite work with Python apparently.

I can get pyenv to build 2.7.5 on my system if I use a command like:

LDFLAGS="-L/usr/local/opt/readline/lib" CFLAGS="-I/usr/local/opt/readline/include" pyenv install 2.7.5

Would you be interested in me developing a patch to make readline compile locally to the python (like openssl does now)? Or maybe at least determining if the user has homebrew installed and using that if it is installed, and telling the user to install homebrew readline if it isn't.

I'm interested in making pyenv as easy to use as possible on OS X, so let me know if there's something I can do.

Why mirroring python?

Just wondering why you had to mirror all python versions, why not just link to the "official" ones?

3.2 installation fails with SSL error

pyenv install command fails when installing 3.2 but succeeds with 3.2.5 and 3.1.5:

ubuntu@box144:~$ pyenv install 3.1.5
Downloading Python-3.1.5.tgz...
-> http://www.python.org/ftp/python/3.1.5/Python-3.1.5.tgz
Installing Python-3.1.5...
Installed Python-3.1.5 to /home/ubuntu/.pyenv/versions/3.1.5

Downloading distribute-0.6.40.tar.gz... [...]
Downloading pip-1.3.1.tar.gz... [...]

ubuntu@box144:~$ pyenv install 3.2.5
Downloading Python-3.2.5.tgz...
-> http://yyuu.github.io/pythons/ed8d5529d2aebc36b53f4e0a0c9e6728
Installing Python-3.2.5...
Installed Python-3.2.5 to /home/ubuntu/.pyenv/versions/3.2.5

Downloading distribute-0.6.40.tar.gz... [...]
Downloading pip-1.3.1.tar.gz... [...]

ubuntu@box144:~$ pyenv install 3.2
Downloading Python-3.2.tgz...
-> http://yyuu.github.io/pythons/5efe838a7878b170f6728d7e5d7517af
Installing Python-3.2...

BUILD FAILED

Inspect or clean up the working tree at /tmp/python-build.20130522214215.31234
Results logged to /tmp/python-build.20130522214215.31234.log

Last 10 log lines:
  File "<string>", line 2, in <module>
  File "/home/ubuntu/.pyenv/versions/3.2/lib/python3.2/ssl.py", line 60, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: No module named _ssl

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 4, in <module>
ImportError: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Build failed on CentOS 6.4

pyenv needs these packages installed first:

  • readline-devel
  • zlib-devel
  • bzip2-devel
  • sqlite-devel
  • openssl-devel

It fails if you execute pyenv install <version> directly.

It seems shims are not working here

MacOSX 10.8
Installed pyenv with home-brew

Added these lines to .profile

# For pyenv 2013-07-14
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
export PYENV_ROOT=/usr/local/opt/pyenv

Ceti$ echo $PATH
/Users/Ceti/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

But there are no shims in /Users/Ceti/.pyenv/shims

So I added the shims location to PATH in .profile /usr/local/Cellar/pyenv/shims:

Ceti$ echo $PATH
/Users/Ceti/.pyenv/shims:/usr/local/Cellar/pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

But commands are always sent to the system python in usr/bin

Ceti$ pyenv versions
* system (set by /usr/local/opt/pyenv/version)
  2.6.8
  2.7.5
  3.3.2
Ceti$ which python
/usr/bin/python
Ceti$ pyenv shell 2.7.5
Ceti$ pyenv versions
  system
  2.6.8
* 2.7.5 (set by PYENV_VERSION environment variable)
  3.3.2
Ceti$ which python
/usr/bin/python
Ceti$ python
Python 2.7.2 (default, Oct 11 2012, 20:14:37) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Did I miss something?

Thanks in advance,
Gene

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.