GithubHelp home page GithubHelp logo

pyenv-virtualenv's Introduction

pyenv-virtualenv

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

Build Status

pyenv-virtualenv is a pyenv plugin that provides features to manage virtualenvs and conda environments for Python on UNIX-like systems.

(NOTICE: If you are an existing user of virtualenvwrapper and you love it, pyenv-virtualenvwrapper may help you (additionally) to manage your virtualenvs.)

Installation

Installing as a pyenv plugin

This will install the latest development version of pyenv-virtualenv into the $(pyenv root)/plugins/pyenv-virtualenv directory.

Important note: If you installed pyenv into a non-standard directory, make sure that you clone this repo into the 'plugins' directory of wherever you installed into.

From inside that directory you can:

  • Check out a specific release tag.
  • Get the latest development release by running git pull to download the latest changes.
  1. Check out pyenv-virtualenv into plugin directory

    $ git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv

    For the Fish shell:

    $ git clone https://github.com/pyenv/pyenv-virtualenv.git (pyenv root)/plugins/pyenv-virtualenv
  2. (OPTIONAL) Add pyenv virtualenv-init to your shell to enable auto-activation of virtualenvs. This is entirely optional but pretty useful. See "Activate virtualenv" below.

    $ echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc

    Fish shell note: Add this to your ~/.config/fish/config.fish

    status --is-interactive; and pyenv virtualenv-init - | source

    Zsh note: Modify your ~/.zshrc file instead of ~/.bashrc.

  3. Restart your shell to enable pyenv-virtualenv

    $ exec "$SHELL"

Installing with Homebrew (for macOS users)

macOS users can install pyenv-virtualenv with the Homebrew package manager. This will give you access to the pyenv-virtualenv command. If you have pyenv installed, you will also be able to use the pyenv virtualenv command.

This is the recommended method of installation if you installed pyenv with Homebrew.

$ brew install pyenv-virtualenv

Or, if you would like to install the latest development release:

$ brew install --HEAD pyenv-virtualenv

After installation, you'll still need to do Pyenv shell setup steps then add

eval "$(pyenv virtualenv-init -)"

to your shell's .rc file (as stated in the caveats). You'll only ever have to do this once.

Usage

Using pyenv virtualenv with pyenv

To create a virtualenv for the Python version used with pyenv, run pyenv virtualenv, specifying the Python version you want and the name of the virtualenv directory. For example,

$ pyenv virtualenv 2.7.10 my-virtual-env-2.7.10

will create a virtualenv based on Python 2.7.10 under $(pyenv root)/versions in a folder called my-virtual-env-2.7.10.

pyenv virtualenv forwards any options to the underlying command that actually creates the virtual environment (conda, virtualenv, or python -m venv). See the output of pyenv virtualenv --help for details.

Create virtualenv from current version

If there is only one argument given to pyenv virtualenv, the virtualenv will be created with the given name based on the current pyenv Python version.

$ pyenv version
3.4.3 (set by /home/yyuu/.pyenv/version)
$ pyenv virtualenv venv34

List existing virtualenvs

pyenv virtualenvs shows you the list of existing virtualenvs and conda environments.

$ pyenv shell venv34
$ pyenv virtualenvs
  miniconda3-3.9.1 (created from /home/yyuu/.pyenv/versions/miniconda3-3.9.1)
  miniconda3-3.9.1/envs/myenv (created from /home/yyuu/.pyenv/versions/miniconda3-3.9.1)
  2.7.10/envs/my-virtual-env-2.7.10 (created from /home/yyuu/.pyenv/versions/2.7.10)
  3.4.3/envs/venv34 (created from /home/yyuu/.pyenv/versions/3.4.3)
  my-virtual-env-2.7.10 (created from /home/yyuu/.pyenv/versions/2.7.10)
* venv34 (created from /home/yyuu/.pyenv/versions/3.4.3)

There are two entries for each virtualenv, and the shorter one is just a symlink.

Activate virtualenv

Some external tools (e.g. jedi) might require you to activate the virtualenv and conda environments.

If eval "$(pyenv virtualenv-init -)" is configured in your shell, pyenv-virtualenv will automatically activate/deactivate virtualenvs on entering/leaving directories which contain a .python-version file that contains the name of a valid virtual environment as shown in the output of pyenv virtualenvs (e.g., venv34 or 3.4.3/envs/venv34 in example above) . .python-version files are used by pyenv to denote local Python versions and can be created and deleted with the pyenv local command.

You can also activate and deactivate a pyenv virtualenv manually:

pyenv activate <name>
pyenv deactivate

Delete existing virtualenv

Removing the directories in $(pyenv root)/versions and $(pyenv root)/versions/{version}/envs will delete the virtualenv, or you can run:

pyenv uninstall my-virtual-env

You can also delete existing virtualenvs by using virtualenv-delete command, e.g. you can run:

pyenv virtualenv-delete my-virtual-env

This will delete virtualenv called my-virtual-env.

virtualenv and venv

There is a venv module available for CPython 3.3 and newer. It provides an executable module venv which is the successor of virtualenv and distributed by default.

pyenv-virtualenv uses python -m venv if it is available and the virtualenv command is not available.

Anaconda and Miniconda

You can manage conda environments by conda create as same manner as standard Anaconda/Miniconda installations. To use those environments, you can use pyenv activate and pyenv deactivate.

$ pyenv version
miniconda3-3.9.1 (set by /home/yyuu/.pyenv/version)
$ conda env list
# conda environments:
#
myenv                    /home/yyuu/.pyenv/versions/miniconda3-3.9.1/envs/myenv
root                  *  /home/yyuu/.pyenv/versions/miniconda3-3.9.1
$ pyenv activate miniconda3-3.9.1/envs/myenv
discarding /home/yyuu/.pyenv/versions/miniconda3-3.9.1/bin from PATH
prepending /home/yyuu/.pyenv/versions/miniconda3-3.9.1/envs/myenv/bin to PATH
$ python --version
Python 3.4.3 :: Continuum Analytics, Inc.
$ pyenv deactivate
discarding /home/yyuu/.pyenv/versions/miniconda3-3.9.1/envs/myenv/bin from PATH

If conda is available, pyenv virtualenv will use it to create environment by conda create.

$ pyenv version
miniconda3-3.9.1 (set by /home/yyuu/.pyenv/version)
$ pyenv virtualenv myenv2
$ conda env list
# conda environments:
#
myenv                    /home/yyuu/.pyenv/versions/miniconda3-3.9.1/envs/myenv
myenv                    /home/yyuu/.pyenv/versions/miniconda3-3.9.1/envs/myenv2
root                  *  /home/yyuu/.pyenv/versions/miniconda3-3.9.1

You can use version like miniconda3-3.9.1/envs/myenv to specify conda environment as a version in pyenv.

$ pyenv version
miniconda3-3.9.1 (set by /home/yyuu/.pyenv/version)
$ pyenv shell miniconda3-3.9.1/envs/myenv
$ which python
/home/yyuu/.pyenv/versions/miniconda3-3.9.1/envs/myenv/bin/python

Special environment variables

You can set certain environment variables to control pyenv-virtualenv.

  • PYENV_VIRTUALENV_CACHE_PATH, if set, specifies a directory to use for caching downloaded package files.
  • VIRTUALENV_VERSION, if set, forces pyenv-virtualenv to install the desired version of virtualenv. If virtualenv has not been installed, pyenv-virtualenv will try to install the given version of virtualenv.
  • GET_PIP, if set and venv is preferred over virtualenv, use get_pip.py from the specified location.
  • GET_PIP_URL, if set and venv is preferred over virtualenv, download get_pip.py from the specified URL.
  • PIP_VERSION, if set and venv is preferred over virtualenv, install the specified version of pip.
  • PYENV_VIRTUALENV_VERBOSE_ACTIVATE, if set, shows some verbose outputs on activation and deactivation

Version History

See CHANGELOG.md.

License

(The MIT License)

  • Copyright (c) 2015 Yamashita, Yuu

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

pyenv-virtualenv's People

Contributors

ackalker avatar adamscharf avatar aiguofer avatar alanyee avatar andrew-christianson avatar anton-petrov avatar aristide-n avatar bartoszj avatar bcb avatar blueyed avatar daogilvie avatar elijahlynn avatar ericvw avatar faho avatar fgimian avatar gauravtalreja1 avatar honza avatar jack-mcivor avatar jcrben avatar lmmarsano avatar native-api avatar puhitaku avatar pygeek avatar s0undt3ch avatar scop avatar shangsunset avatar silverjam avatar ushuz avatar wwwjfy avatar yyuu 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

pyenv-virtualenv's Issues

Virtual env creation not working with very last version

On OpenSuse 12.1 with a custom pyenv home path.

There's no error :

pyenv virtualenv 2.6.8 custom_py2.6.8_2
New python executable in /datas/libs/pyenv/versions/custom_py2.6.8_2/bin/python
Installing setuptools, pip...done.

The new env directory isn't created in .../versions and isn't listed by pyenv versions.

The same command is ok with v20140110.1 tag.

Versions :

  • pyenv 0.4.0-20140110.1-8-g385d333
  • pyenv-virtualenv 20140110.1 (virtualenv 1.11)

Feature suggestion: clone virtualenv to new env

While working on different library version it would be extremely helpful to be able to clone an existing virtualenv.

Right now what I do is:

  1. pip freeze > requirements.txt in the current virtualenv
  2. pyenv virtualenv ...
  3. pyenv shell newvirtualenv
  4. pip install -r requirements.txt

Not too bad, but it could be easier.

error: pyenv activate

I've installed pyenv and pyenv-virtualenv. pyenv seems to be working great, and it appears I am able to create a virtualenv, but I can not seem to activate the virtualenv.

test3.3 >> pyenv virtualenvs
  py276 (created from /Users/insomniac/.pyenv/versions/2.7.6)
  py333 (created from /Users/insomniac/.pyenv/versions/3.3.3)
test3.3 >> pyenv activate py333
pyenv: no such command `activate'

How can I activate the virtual env? Also, is there a way to auto-activate and auto-deactivate the virtual environment when I go in and out of the directory?

Thanks,
C.

pydoc3 link to existing Python install

Not sure if I did something wrong, but seems that the venv environment lacks of the pydoc link to the installed pyenv Python version, i.e, it's calling the system default instance from within the virtualenv, instead of the installed pyenv version it depends on.

Happened with pyenv + virtualenv of 3.4.2 python version:

pyenv activate/deactivate not working

I am having trouble activating a virtual environment with "pyenv activate".

I restarted my machine and am working in a fresh shell.
I have pyenv installed and it appears to be working correctly.

~ >> pyenv versions
  system
* 2.7.6 (set by /Users/insomniac/.pyenv/version)
  3.3.3

I create a new project and set the python version with pyenv:

>> mkdir myproj
>> cd myproj
myproj >> pyenv local 3.3.3
myproj >> pyenv local
3.3.3

I then create a virtualenv called "foo" and double check it was created

myproj >> pyenv virtualenv foo333

myproj >> pyenv virtualenvs
  foo333 (created from /Users/insomniac/.pyenv/versions/3.3.3)

If I list pyenv versions, it's showing in the list, so I assume the virtual environments are being saved in the same location (this is a bit confusing).

myproj >> pyenv versions
  system
  2.7.6
* 3.3.3 (set by /Users/insomniac/Repo/myproj/.python-version)
  foo333

If I try to active the "foo333" virtual environment for "myproject" I get the following error:

myproj >> pyenv activate foo333
pyenv: no such command `activate'

I restart my shell and try again with the same result:

myproj >> pyenv local
3.3.3
myproj >> pyenv virtualenvs
  foo333 (created from /Users/insomniac/.pyenv/versions/3.3.3)
myproj >> pyenv activate foo333
pyenv: no such command `activate'
myproj >> 

I am able to activate 'foo333' with the following command:

myproj >> source "$(pyenv prefix foo333)/bin/activate"
(foo333) myproj >>

If I try to deactivate - I can only use "deactivate" - I get the same error if I use pyenv deactivate

(foo333) myproj >> pyenv deactivate
pyenv: no such command `deactivate'

(foo333) myproj >> deactivate
myproj >> 

I installed pyenv-virtualenv this morning using "brew install".
Any ideas?

Thanks,
C.

Activating virtualenvs fail with the fish shell

Hey there, I've noticed that activating a virtualenv on the fish shell doesn't work. I tested this with a fresh Ubuntu 14.04 install and a new copy of pyenv.

fots@fotsies-ubtrusty-01~> pyenv global 2.7.6
fots@fotsies-ubtrusty-01~> pyenv virtualenv flaskage
Downloading/unpacking virtualenv
  Downloading virtualenv-1.11.6-py2.py3-none-any.whl (1.6MB): 1.6MB downloaded
Installing collected packages: virtualenv
Successfully installed virtualenv
Cleaning up...
New python executable in /home/fots/.pyenv/versions/flaskage/bin/python
Installing setuptools, pip...done.
fots@fotsies-ubtrusty-01~> pyenv activate flaskage
pyenv: version `/home/fots/.pyenv/versions/flaskage/bin/activate.fish' not installed
fots@fotsies-ubtrusty-01~>

Activating the virtualenv manually seems to work:

fots@fotsies-ubtrusty-01~> . /home/fots/.pyenv/versions/flaskage/bin/activate.fish
(flaskage)fots@fotsies-ubtrusty-01~> which python
/home/fots/.pyenv/versions/flaskage/bin/python
(flaskage)fots@fotsies-ubtrusty-01~> pyenv deactivate
fots@fotsies-ubtrusty-01~>

Your help on this would be greatly appreciated! ๐Ÿ˜„
Fotis

2to3 not found in virtualenv, causing an error during package installation via pip

Hi,

I just installed a 3.3.5 version in pyenv on a Debian Wheezy. Then I made a virtualenv using pyenv-virtualenv. And the last part, I did a pip install -r requirements.txt.

And I got this error while installing a dependancy:

subprocess.CalledProcessError: Command '['2to3', '-wn', 'build/lib/logilab/common/test/data']' returned non-zero exit status 127

When I execute 2to3 command, I have this result:

(tickets) root@infra-tool01:/srv/tickets/tickets# 2to3
pyenv: 2to3: command not found

The `2to3' command exists in these Python versions:
  3.3.5

It seems 2to3 command executed is the one in shims:

(tickets) root@infra-tool01:/srv/tickets/tickets# which 2to3
/srv/tickets/pyenv/shims/2to3

Here is my $PATH:

(tickets) root@infra-tool01:/srv/tickets/tickets# echo $PATH
/srv/tickets/pyenv/versions/tickets/bin:/srv/tickets/pyenv/shims:/srv/tickets/pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

I did a pyenv rehash outside and inside the virtualenv, nothing changed.

Any idea?

Best regards,
Alexis.

Virtualenv creation does not seem to work correctly

Hi!

I have been having some problems creating new virtualenvs using the pyenv-virtualenv plugin. If I issue the following command in terminal:
pyenv virtualenv 3.3.5 myenv
This is what the terminal outputs:

pyenv virtualenv [-f|--force] [-u|--upgrade] [VIRTUALENV_OPTIONS] <version> <virtualenv-name>
       pyenv virtualenv --version
       pyenv virtualenv --help

  -u/--upgrade     Upgrade existing virtualenv to use new version of Python,
                   assuming Python has been upgraded in-place.
  -f/--force       Install even if the version appears to be installed already

I'm certain that I am inputting the command correctly, as I have used this plugin before without any issues. I am running a fresh install of Ubuntu 14.04, and all of my pyenv packages are up to date. I'm hoping that this isn't just a stupid oversight on my part!

Matt

Cannot properly uninstall virtualenv

Hi,

I have been messing around with this for a few minutes and I can't quite figure out what the issue is. So I made a virtualenv to test out pyechonest for my brother, and once I was done I went to delete the virtualenv. First I simply deleted the directory containing the virtualenv. I have done this in the past and it has worked fine.

Now I get spammed with the following messages every time I execute any command in the terminal:

pyenv: version `echonest2' is not installed
pyenv: version `echonest2' not installed
pyenv: version `echonest2' is not installed

echonest2 is the name of the virtualenv that I created.

I have also tried using pyenv uninstall echonest2 and that didn't seem to help either. The only way I can get these messages to stop showing up is to take the stuff related to pyenv out of my .bashrc. I have even tried completely uninstalling pyenv (by deleting the .pyenv) directory, and that still didn't solve it.

Hopefully this makes sense.

Thanks!

P.S. I am running Arch Linux if that makes any difference.

Post install package for every virtualenv created

Is it possible to have a post install hook so that every time a new virtualenv is created a package is installed too?

The use case is simple: i'd like - in the same way pip is installed - to have iPython installed automatically with every pyenv virtualenv created.

Major problems with current version of pyenv-virtualenv

Hey there Yuu, hope you're well ๐Ÿ˜„

Since some of the latest commits, I've been having quite a few major problems with this extension I'm afraid.

My test system is a fresh install of Ubuntu Server 12.04 with the regular bash shell.

This output should explain the problems ๐Ÿ˜„

fots@fotsies-ubprecise-02:~$ pyenv versions
* system (set by /home/fots/.pyenv/version)
  2.7.7
  3.4.1
fots@fotsies-ubprecise-02:~$ python -V
Python 2.7.3
fots@fotsies-ubprecise-02:~$ pyenv global 2.7.7
fots@fotsies-ubprecise-02:~$ python -V
Python 2.7.7
fots@fotsies-ubprecise-02:~$ pyenv virtualenv newproject
New python executable in /home/fots/.pyenv/versions/newproject/bin/python
Installing setuptools, pip...done.
fots@fotsies-ubprecise-02:~$ pyenv activate newproject
(newproject)fots@fotsies-ubprecise-02:~$ python -V
Python 2.7.3
(newproject)fots@fotsies-ubprecise-02:~$ pyenv deactivate
(newproject)fots@fotsies-ubprecise-02:~$ unset PYENV_VERSION
fots@fotsies-ubprecise-02:~$ pyenv virtualenv 2.7.7 newproject2
New python executable in /home/fots/.pyenv/versions/newproject2/bin/python
Installing setuptools, pip...done.
fots@fotsies-ubprecise-02:~$ pyenv activate newproject2
(newproject2)fots@fotsies-ubprecise-02:~$ python -V
Python 2.7.3
(newproject2)fots@fotsies-ubprecise-02:~$

So in summary:

  • Creating a virtualenv always uses the system version of Python
  • Deactivating a virtualenv no longer correctly unsets the PYENV_VERSION environment variable

Your help would be greatly appreciated
Fotis

Can't create a virtualenv with python3.4

With the default python2.7 it works fine, but it fails when I specify python3
Both pythons, pyenv and pyenv-virtualenv have been installed through brew.
The error message seems quite clear but I don't have a clue how to solve it.

$ pyenv virtualenv --python=/usr/local/bin/python3  matrix
Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local/Cellar/python3/3.4.1/Frameworks/Python.framework/Versions/3.4'
New python executable in /Users/hernan/.pyenv/versions/matrix/bin/python3.4
Also creating executable in /Users/hernan/.pyenv/versions/matrix/bin/python
Failed to import the site module
Traceback (most recent call last):
  File "/Users/hernan/.pyenv/versions/matrix/bin/../lib/python3.4/site.py", line 67, in <module>
    import os
  File "/Users/hernan/.pyenv/versions/matrix/bin/../lib/python3.4/os.py", line 614, in <module>
    from _collections_abc import MutableMapping
ImportError: No module named '_collections_abc'
ERROR: The executable /Users/hernan/.pyenv/versions/matrix/bin/python3.4 is not functioning
ERROR: It thinks sys.prefix is '/Users/hernan/.pyenv/cache' (should be '/Users/hernan/.pyenv/versions/matrix')
ERROR: virtualenv is not compatible with this system or executable
$

Can not deactivate virtual environment

I activate an virtualenv called study3 with the command pyenv activate study3. In this time, I have my python in the version of study3

Then I want to deactivate study3 and I input the command pyenv deactivate study3 or pyenv deactivate study3 and I get no result. I still have the version of study3.

Is there anything I did wrong or do I have some misunderstanding about the command?

pyenv-virtualenv deactivate automatically any virtualenvironment

If I activate any environment without pyenv shell env then it'll automatically deactivated with next command

$ cd ~/data
$ virtualenv venv
$ . venv/bin/activate
$ echo $VIRTUAL_ENV
/home/user/data/venv
$ pip install pyflake8 #actually any command
$ echo $VIRTUAL_ENV

$ echo :(

My configuration

export PATH=$HOME/.pyenv/bin:$PATH
if type pyenv 1> /dev/null 2>&1
then
    eval "$(pyenv init -)"
    eval "$(pyenv virtualenv-init -)"
fi

Use chpwd hook for _pyenv_virtualenv_hook / internal hook system with pyenv

I wonder if it would be a good idea to use the chpwd hook (instead of precmd (for zsh)) with the hook that gets installed via pyenv virtualenv init -:

_pyenv_virtualenv_hook () {
  if [ -n "$PYENV_ACTIVATE" ]
  then
    if [ "$(pyenv version-name)" = "system" ]
    then
      pyenv deactivate --no-error --verbose
      return 0
    fi
    if [ "$PYENV_ACTIVATE" != "$(pyenv prefix)" ]
    then
      if pyenv deactivate --no-error --verbose
      then
        pyenv activate --no-error --verbose || unset PYENV_DEACTIVATE
      else
        pyenv activate --no-error --verbose
      fi
    fi
  else
    if [ -z "$VIRTUAL_ENV" ] && [ "$PYENV_DEACTIVATE" != "$(pyenv prefix)" ]
    then
      pyenv activate --no-error --verbose
    fi
  fi
}

Alternatively, pyenv itself could have a hook system, where changing the version (e.g. via pyenv shell) would notify the pyenv-virtualenv plugin and that could call activate then (based on some config).

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/4224688-use-chpwd-hook-for-_pyenv_virtualenv_hook-internal-hook-system-with-pyenv?utm_campaign=plugin&utm_content=tracker%2F335155&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F335155&utm_medium=issues&utm_source=github).

pyenv deactivate command doesn't work propery

Activating the virtualenv works perfectly but when in need to deactivate using "pyenv deactivate" command the PS1 remove the environment name but when you check which active version using "pyenv version" the deactivated environment is still active. Something maybe wrong.

screen shot 2014-12-22 at 6 50 56 pm

Command for temporary environments

Some times we just want to try some library, it would be nice to have something along the lines of the following to easily create a disposable environment.

#!/bin/sh
# TODO: generate a unique name if none given
# TODO: allow to define a base environment
pyenv virtualenv "$1"

echo "Entering a new shell session with version '$1'"
echo "Press ctrl+d or exit to terminate it" 

export PYENV_VERSION="$1"
$SHELL

echo "Destroying temp version '$1'"
pyenv uninstall -f "$1"

activate/deactivate script hooks?

I wanted to just confirm that there isn't any automatic facility in pyenv or pyenv-virtualenv for hooks like the way virtualenvwrapper provides postactivate and postdeactivate scripts. I'm mostly interested in the setting of environment variables when a version activates.

I'm fine with leaving virtualenvwrapper behind (or else I'd play with pyenv-virtualenvwrapper), but I figured I should find out for sure if there is any similar functionality available to me. I didn't see anything along these lines on https://github.com/yyuu/pyenv/wiki/Plugins

Thanks in advance for any info one way or the other!

PATH environment variable does not get updated

pyenv-virtualenv does not seem to handle scripts that gets installed in the bin directory. Albeit the installation procedure seems to be fine, the plugin does not actually export in the PATH environment variable the bin path.

For example if I try to install Twisted, from the setup logs I can clearly see that scripts are correctly installed under /Users/whatever/.pyenv/versions/demo-2.7.5/bin/twistd but the environment variable PATH is not set to include the folder /Users/whatever/.pyenv/versions/demo-2.7.5/bin/.

pyenv global not setting the env correctly

:~[103] > pyenv versions
  system
  3.4.1
  jython-2.5.3
:~[104] > python --version
Python 2.7.8
:~[105] > pyenv global 3.4.1
:~[106] > pyenv versions
  system
* 3.4.1 (set by /Users/christoperjung/.pyenv/version)
  jython-2.5.3
:~[107] > python --version
Python 2.7.8

It seems like pyenv global's not working properly. How can I fix this issue?

Anaconda 1.9.1 install detects Darwin-x86_64 architecture, returns error

On OS X 10.8.5, running pyenv install anaconda-1.9.1 returns:

ERRORPrecompiled binary of anaconda-1.9.1 is not available for Darwin-x86_64.

It appears that what should happen is that anaconda_architecture (in plugins/python-build/share/python-build/anaconda-1.9.1) should return MacOSX-x86_64; it returns Darwin-x86_64 instead.

Python 2.4.6 needs virtualenv 1.7.2

Hi everyone, I didn't find where to fix it.. in my pc I'm uninstalling / installing by hand with:
$ pyenv global 2.4.6
$ pip uninstall virtualenv
$ easy_install virtualenv==1.7.2

Could you please fix the version of virtualenv with python 2.4.6?

pyenv-virtualenv breaks pyenv

I installed pyenv ealier and everything was working great. I installed python2.7.6 with pyenv as per the documentation and tested it - everything was working fine. Every time I went into the test2.7 folder and checked the python version everything seemed correct - python 2.7.6 was being used.

After installing the pyenv-virtualenv plugin, the system version of python is being used, not the one set with pyenv.

I did not make any changes to my .bash_profile after the initial installation of pyenv, so I'm not sure why this has stopped working.

test2.7 >> cat .python-version 
2.7.6
test2.7 >> pyenv local
2.7.6
test2.7 >> python
Python 2.7.5 (default, Aug 25 2013, 00:04:04) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

pyenv virtualenv not matching ucs4 installation

I'm trying to install a virtual environment that uses UCS-4 encoding. I've installed my base python installation with:

PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs4" pyenv install 2.7.5
mv $PYENV_ROOT/versions/2.7.5 $PYENV_ROOT/versions/2.7.5_ucs4
pyenv install 2.7.5
pyenv global 2.7.5_ucs4

If I run python -c "import sys; print sys.maxunicode", it prints 1114111, indicating that UCS-4 is installed. When I then run:

pyenv virtualenv vEnv
pyenv local vEnv
python -c "import sys; print sys.maxunicode"

it prints out 65535, indicating UCS-2 is installed.

Should I be doing something differently?

Upgrading virtualenvs

I tried to upgrade 3.4.1 based virtualenv to 3.4.2:

Alexanders-MacBook-Air:~ lorddaedra$ pyenv virtualenv 3.4.2 byvshie
pyenv-virtualenv: /Users/lorddaedra/.pyenv/versions/byvshie already exists
continue with installation? (y/N) y

but it's still has python3.4 symlink to 3.4.1(not 3.4.2 as expected)

(byvshie) Alexanders-MacBook-Air:~ lorddaedra$ ls -al ~/.pyenv/versions/byvshie/bin/
total 272
drwxr-xr-x  34 lorddaedra  staff   1156 15 ะพะบั‚ 13:56 .
drwxr-xr-x   6 lorddaedra  staff    204 15 ะพะบั‚ 13:56 ..
drwxr-xr-x   8 lorddaedra  staff    272 15 ะพะบั‚ 13:56 __pycache__
-rw-r--r--   1 lorddaedra  staff   2163 16 ะพะบั‚ 02:56 activate
-rw-r--r--   1 lorddaedra  staff   1279 16 ะพะบั‚ 02:56 activate.csh
-rw-r--r--   1 lorddaedra  staff   2415 16 ะพะบั‚ 02:56 activate.fish
-rwxr-xr-x   1 lorddaedra  staff    305  4 ัะตะฝ 14:49 django-admin
-rwxr-xr-x   1 lorddaedra  staff    164  4 ัะตะฝ 14:49 django-admin.py
-rwxr-xr-x   1 lorddaedra  staff    272 12 ะพะบั‚ 16:43 easy_install
-rwxr-xr-x   1 lorddaedra  staff    272 12 ะพะบั‚ 16:43 easy_install-3.4
-rwxr-xr-x   1 lorddaedra  staff   3670  2 ะพะบั‚ 04:34 jwt
-rw-r--r--   1 lorddaedra  staff   2369 15 ะพะบั‚ 13:56 pilconvert.py
-rw-r--r--   1 lorddaedra  staff  15636 15 ะพะบั‚ 13:56 pildriver.py
-rw-r--r--   1 lorddaedra  staff   2614 15 ะพะบั‚ 13:56 pilfile.py
-rw-r--r--   1 lorddaedra  staff   1060 15 ะพะบั‚ 13:56 pilfont.py
-rw-r--r--   1 lorddaedra  staff   2415 15 ะพะบั‚ 13:56 pilprint.py
-rwxr-xr-x   1 lorddaedra  staff    244 17 ะธัŽะฝ 23:46 pip
-rwxr-xr-x   1 lorddaedra  staff    244 17 ะธัŽะฝ 23:46 pip3
-rwxr-xr-x   1 lorddaedra  staff    244 17 ะธัŽะฝ 23:46 pip3.4
lrwxr-xr-x   1 lorddaedra  staff      9 17 ะธัŽะฝ 23:46 python -> python3.4
lrwxr-xr-x   1 lorddaedra  staff      9 17 ะธัŽะฝ 23:46 python3 -> python3.4
lrwxr-xr-x   1 lorddaedra  staff     53 17 ะธัŽะฝ 23:46 python3.4 -> /Users/lorddaedra/.pyenv/versions/3.4.1/bin/python3.4
-rwxr-xr-x   1 lorddaedra  staff    331 15 ะพะบั‚ 13:56 raven
-rwxr-xr-x   1 lorddaedra  staff    633  6 ะพะบั‚ 17:56 rst2html.py
-rwxr-xr-x   1 lorddaedra  staff    830  6 ะพะบั‚ 17:56 rst2latex.py
-rwxr-xr-x   1 lorddaedra  staff    639  6 ะพะบั‚ 17:56 rst2man.py
-rwxr-xr-x   1 lorddaedra  staff    803  6 ะพะบั‚ 17:56 rst2odt.py
-rwxr-xr-x   1 lorddaedra  staff   1737  6 ะพะบั‚ 17:56 rst2odt_prepstyles.py
-rwxr-xr-x   1 lorddaedra  staff    640  6 ะพะบั‚ 17:56 rst2pseudoxml.py
-rwxr-xr-x   1 lorddaedra  staff    676  6 ะพะบั‚ 17:56 rst2s5.py
-rwxr-xr-x   1 lorddaedra  staff    825  6 ะพะบั‚ 17:56 rst2xetex.py
-rwxr-xr-x   1 lorddaedra  staff    641  6 ะพะบั‚ 17:56 rst2xml.py
-rwxr-xr-x   1 lorddaedra  staff    709  6 ะพะบั‚ 17:56 rstpep2html.py
-rwxr-xr-x   1 lorddaedra  staff   3891 12 ะพะบั‚ 16:43 sqlformat
(byvshie) Alexanders-MacBook-Air:~ lorddaedra$

"activate" command breaks fish-shell PS1

In my current oh-my-fish theme (numist) I type command in the second line, but when I activate my pyenv-virtualenv it breaks and goes back to the same line as the other info. Check the screenshot for details.

image

New virtualenv installs all site packages by default

I can't seem to create a virtualenv without all the site packages being included. I used the --no-site-packages option and that worked fine last night. For some reason today, that option is no longer available. It says new envs will have no site packages included by default but it doesnt seem to be the case for me.

pyenv-virtualenv initialisation failing.

When running $ eval "$(pyenv virtualenv-init -)", I always get this error message:

Failed to deactivate virtualenv.

Perhaps pyenv-virtualenv has not been loaded into your shell properly.
Please restart current shell and try again.

For some reason, I can still use it on the same shell I installed it in, but not any other shell. How do I load up pyenv-virtualenv properly? Note: I Installed it using Homebrew.

I just realised I have issues with my virtualenv:

$ python
-bash: /Users/ncopty/.pyenv/versions/finprod/bin/python: No such file or directory
$ ~/.virtualenvs/finprod/bin/python
Python 2.7.2 (default, Jul  2 2014, 14:30:17) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.34.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

Which one is the correct one and why do I have two?

Creating a 3.4.0 virtualenv fails under OS X Yosemite

It seems to fail installing pip. I got the following in ~/.pip/pip.log:

------------------------------------------------------------
-c run on Sat Nov  8 11:48:21 2014
Ignoring indexes: https://pypi.python.org/simple/
Downloading/unpacking setuptools
  URLs to search for versions for setuptools:
  Skipping link . (from -f); not a file
  Skipping link /Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages (from -f); not a file
  Skipping link /Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support (from -f); not a file
  Skipping link file:///Users/valrus/.pyenv/cache/pip-1.5.6.tar.gz; wrong project name (not setuptools)
  Skipping link file:///Users/valrus/.pyenv/cache/Python-2.7.7.tgz; wrong project name (not setuptools)
  Found link file:///Users/valrus/.pyenv/cache/setuptools-5.0.tar.gz, version: 5.0
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/__pycache__; not a file
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/_markerlib; not a file
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/clonevirtualenv.py; unknown archive format: .py
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/easy_install.py; unknown archive format: .py
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/IPython; not a file
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/ipython-1.2.1-py3.4.egg-info; unknown archive format: .egg-info
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/pip; not a file
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/pip-1.5.4.dist-info; unknown archive format: .dist-info
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/pkg_resources.py; unknown archive format: .py
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/README; not a file
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/setuptools; not a file
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/setuptools-2.1.dist-info; unknown archive format: .dist-info
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/stevedore; not a file
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/stevedore-0.14.1-py3.4.egg-info; unknown archive format: .egg-info
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv-1.11.4.dist-info; unknown archive format: .dist-info
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv.py; unknown archive format: .py
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_clone-0.2.4-py3.4.egg-info; unknown archive format: .egg-info
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support; not a file
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenvwrapper; not a file
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenvwrapper-4.2-py3.4-nspkg.pth; unknown archive format: .pth
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenvwrapper-4.2-py3.4.egg-info; unknown archive format: .egg-info
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/__init__.py; unknown archive format: .py
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/__pycache__; not a file
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl; wrong project name (not setuptools)
  Found link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/setuptools-2.2-py2.py3-none-any.whl, version: 2.2
  Local files found: /Users/valrus/.pyenv/cache/setuptools-5.0.tar.gz, /Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/setuptools-2.2-py2.py3-none-any.whl
  Using version 5.0 (newest of versions: 5.0, 2.2)
  Running setup.py (path:/Users/valrus/.pyenv/versions/tweepy/build/setuptools/setup.py) egg_info for package setuptools
    running egg_info
    creating pip-egg-info/setuptools.egg-info
    writing top-level names to pip-egg-info/setuptools.egg-info/top_level.txt
    writing requirements to pip-egg-info/setuptools.egg-info/requires.txt
    writing dependency_links to pip-egg-info/setuptools.egg-info/dependency_links.txt
    writing entry points to pip-egg-info/setuptools.egg-info/entry_points.txt
    writing pip-egg-info/setuptools.egg-info/PKG-INFO
    writing manifest file 'pip-egg-info/setuptools.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'pip-egg-info/setuptools.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'pip-egg-info/setuptools.egg-info/SOURCES.txt'
  Source in /Users/valrus/.pyenv/versions/tweepy/build/setuptools has version 5.0, which satisfies requirement setuptools
  skipping extra certs
  skipping extra ssl:sys_platform=='win32'
Downloading/unpacking pip
  URLs to search for versions for pip:
  Found link file:///Users/valrus/.pyenv/cache/pip-1.5.6.tar.gz, version: 1.5.6
  Skipping link file:///Users/valrus/.pyenv/cache/Python-2.7.7.tgz; wrong project name (not pip)
  Skipping link file:///Users/valrus/.pyenv/cache/setuptools-5.0.tar.gz; wrong project name (not pip)
  Found link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl, version: 1.5.4
  Skipping link file:///Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/setuptools-2.2-py2.py3-none-any.whl; wrong project name (not pip)
  Local files found: /Users/valrus/.pyenv/cache/pip-1.5.6.tar.gz, /Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl
  Using version 1.5.6 (newest of versions: 1.5.6, 1.5.4)
  Running setup.py (path:/Users/valrus/.pyenv/versions/tweepy/build/pip/setup.py) egg_info for package pip
    /Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'tests_require'
      warnings.warn(msg)
    /Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'zip_safe'
      warnings.warn(msg)
    /Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'extras_require'
      warnings.warn(msg)
    /Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'entry_points'
      warnings.warn(msg)
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help

    error: invalid command 'egg_info'
    Complete output from command python setup.py egg_info:
    /Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'tests_require'

  warnings.warn(msg)

/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'zip_safe'

  warnings.warn(msg)

/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'extras_require'

  warnings.warn(msg)

/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'entry_points'

  warnings.warn(msg)

usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]

   or: -c --help [cmd1 cmd2 ...]

   or: -c --help-commands

   or: -c cmd --help



error: invalid command 'egg_info'

----------------------------------------
Cleaning up...
  Removing temporary dir /Users/valrus/.pyenv/versions/tweepy/build...
Command python setup.py egg_info failed with error code 1 in /Users/valrus/.pyenv/versions/tweepy/build/pip
Exception information:
Traceback (most recent call last):
  File "/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl/pip/req.py", line 1229, in prepare_files
    req_to_install.run_egg_info()
  File "/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl/pip/req.py", line 325, in run_egg_info
    command_desc='python setup.py egg_info')
  File "/Users/valrus/.pyenv/versions/3.4.0/lib/python3.4/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl/pip/util.py", line 697, in call_subprocess
    % (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command python setup.py egg_info failed with error code 1 in /Users/valrus/.pyenv/versions/tweepy/build/pip

Unable to select which system Python version to use.

I have two system Pythons installed: 2.7.5 and 3.2. When creating a virtual env:

pyenv virtualenv system foo

I can't select which one to use. The default (2.7.5) is always used. I tried aliasing:

~$ alias python=python3
~$ pyenv virtualenv system foo

I also tried changing the python shim to always run python3 by changing the last line to:

exec "/home/tomas/.pyenv/libexec/pyenv" exec "python3" "$@"

right before creating the virtual env. In both cases, version 2.7.5 was still used. Creating the virtual env manually worked:

~$ pyenv shell system
~$ virtualenv -p `pyenv which python3` --system-site-packages .pyenv/versions/photo_organizer

Pyenv virtualenv installing in different location than the PYENV_ROOT path

I've already installed few virtualenvs (those virtualenvs are listed down when i check pyenv virtualenvs in /usr/local/opt/pyenv/versions)

In zshrc i've added these lines

export PYENV_ROOT="/usr/local/opt/pyenv"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

$PYENV_ROOT is available in shell

echo $PYENV_ROOT : /usr/local/opt/pyenv

But if i try to install new pyenv version and using it creating a new virtualenv, the installation goes in different folder (i guess default) ~/.pyenv

Because of that my new virtualenv is not available (in pyenv virtualenvs, hence i can't use it)

  1. What is the issue? Why it's installing in other location than the pyenv_root?
  2. Is it possible to tell pyenv virtualenv that virtualenvs are in 2 locations? (adding the current location?) or how to solve this?

How does the auto activation/ deactivation works?

I'm running Mac 10.9.5 and i did the installation as below:

brew install pyenv
eval "$(pyenv init -)" >> ~/.bashrc
brew install pyenv-virtualenv
eval "$(pyenv virtualenv-init -)" >> ~/.bashrc

The installation home is all under

pyenv versions
* system (set by /usr/local/opt/pyenv/version)
  3.4.2
  ra1

[dani@localhost in ~]# ll /usr/local/opt/pyenv*
lrwxr-xr-x  1 dani  admin    24B Oct 22 16:27 /usr/local/opt/pyenv -> ../Cellar/pyenv/20141012
lrwxr-xr-x  1 dani  admin    35B Oct 22 16:38 /usr/local/opt/pyenv-virtualenv -> ../Cellar/pyenv-virtualenv/20141012

I read the other issues - #47 , #48, #32 , #33 and i've followed the same steps as in #32 (i get this are the manual steps)

[dani@localhost in ~]# pyenv versions
* system (set by /usr/local/opt/pyenv/version)
  3.4.2
  ra1
[dani@localhost in ~]# python -V
Python 2.7.6
[dani@localhost in ~]# echo PYENV_ACTIVATED
PYENV_ACTIVATED
[dani@localhost in ~]# echo $PYENV_ACTIVATED

[dani@localhost in ~]# echo $PYENV_DEACTIVATED

[dani@localhost in ~]# echo $PYENV_VIRTUALENV_INIT
1
[dani@localhost in ~]# pyenv activate ra1
(ra1) [dani@localhost in ~]# python -V
Python 3.4.2
(ra1) [dani@localhost in ~]# echo $PYENV_ACTIVATED

(ra1) [dani@localhost in ~]# echo $PYENV_DEACTIVATED

(ra1) [dani@localhost in ~]# echo $PYENV_VERSION
ra1
(ra1) [dani@localhost in ~]# pyenv deactivate
[dani@localhost in ~]# echo $PYENV_VERSION
ra1
[dani@localhost in ~]# echo $PYENV_DEACTIVATED

[dani@localhost in ~]# echo $PYENV_ACTIVATED

[dani@localhost in ~]# pyenv version
ra1 (set by PYENV_VERSION environment variable)
[dani@localhost in ~]# pyenv versions
  system
  3.4.2
* ra1 (set by PYENV_VERSION environment variable)
[dani@localhost in ~]#

BUT because the above behavior, when i'm trying to uninstall the virtual env i get this error

[dani@localhost in ~]# pyenv uninstall ra1
pyenv: remove /usr/local/opt/pyenv/versions/ra1? y
[dani@localhost in ~]# pyenv versions
pyenv: version `ra1' is not installed
  system
  3.4.2

In #47 you mentioned,

As you mentioned, PYENV_DEACTIVATED should not persist after automatically triggered deactivation. I'll try to fix it in #47.

hence my question: _what is the working flow for the auto activation/ deactivation? Do i need to be inside the PYENV_ROOT in order for auto activation to kick in?_

In addition to this issue, according to the README file, the pyenv-virtualenv should be registered as a plugin inside pyenv, is this a bug in the brew formula's installation?

[dani@localhost in ~]# ll /usr/local/opt/pyenv/plugins/
total 8
lrwxr-xr-x  1 dani  admin    61B Oct 22 16:27 python-build -> /usr/local/Cellar/pyenv/20141012/default-plugins/python-build

Running Tox inside a pyenv virutalenv

It seems like you can't use Tox to test against multiple Python versions inside of a virtualenv created with pyenv-virtualenv. From what I can tell, this is because activating a pyenv-virtualenv sets the PYENV_VERSION to the named virtualenv, which makes all the other pythonX.Y shims invalid.

A complete example demonstrating this problem:

$> pyenv install 2.7.6
$> pyenv install 3.4.1
$> pyenv global 2.7.6 3.4.1
$> pyenv versions
  system
* 2.7.6 (set by /Users/andy/.pyenv/version)
* 3.4.1 (set by /Users/andy/.pyenv/version)

# NOTE, installing tox "globally" here and running it
# against 2.7.6 and 3.4.1 works fine because both
#2.7.6 and 3.4.1 are "activated" in the non-virtualenv
# environment

$> pyenv virtualenv 2.7.6 redis-py
$> pyenv activate redis-py
$> pyenv versions
  system
  2.7.6
  3.4.1
* redis-py (set by PYENV_VERSION environment variable)

# Now Tox (or any other program trying to call python3.4) will fail

$> python3.4
pyenv: python3.4: command not found

The `python3.4' command exists in these Python versions:
  3.4.1

I've gotten around this problem by using pyenv-virtualenvwrapper, which doesn't seem to use the pyenv versions system to create the virtualenv and doesn't set the PYENV_VERSION environment variable.

pyenv not playing nice with brew

I installed python 2.7.6 and python 3.3.3 with pyenv.

Now when I run brew doctor I get the following warning:

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/insomniac/.pyenv/shims/python-config
    /Users/insomniac/.pyenv/shims/python2-config
    /Users/insomniac/.pyenv/shims/python2.7-config
    /Users/insomniac/.pyenv/shims/python3-config
    /Users/insomniac/.pyenv/shims/python3.3-config
    /Users/insomniac/.pyenv/shims/python3.3m-config

How can this be fixed so it plays nice with brew?
C.

Activation / Deactivation of virtualenvs works only once

I have a project in which I created a .python-version file. In this case I have something like:

$ cat project/.python-version
project-2.7.8

Whenever I change my directory to the project root pyenv-virtualenv is invoked correctly. When I leave the virtual env is deactivated.

$ cd project
pyenv-virtualenv: activate project-2.7.8
(project-2.7.8) $ cd ..
pyenv-virtualenv: deactivate project-2.7.8

The problem is that if I re-enter in the project/ directory is not activated anymore.

$ cd project
# Nothing happens
$

It doesn't matter how many times I try, the activation seems to work only once. Successive attempts seem to ignore the virtualenv indicated in the .python-version file.

error: Could not find an activated virtualenv (required).

For starters, I must state that I'm new at working with python in virtual environments, so please forgive me if I'm missing something obvious.

I want to create isolated projects with different versions of python and python packages.

I installed pyenv and that seems to be working fine. I installed various versions of python and set "pyenv local 3.3.3" and when I check the python version, everything seems correct.

I then installed pyenv-virtualenv, since the documentation states that 'pyenv' does not manage the virtual environments and to use 'pyenv-virtualenv' to make it easier.

I ran brew the following command to install pyenv-virtualenv:
~>> brew install pyenv-virtualenv
and everything seemed to run ok.

I then created and changed into a new directory 'test'. I ran the command based on the documentation and get the following error:

Repo >> mkdir test
Repo >> cd test
test >> pyenv virtualenv 2.7.6 mytestenv
Could not find an activated virtualenv (required).

I was under the assumption that pyenv virtualenv would create a virtual environment called 'mytestenv' using python 2.7.6. I'm not sure if I need to add something to my .bash_profile in order to get this to work. I have a lot of stuff in there from before since I had previously installed the regular version of virtualenv and virtualenvwrapper.

Can someone please explain how this is supposed to be used so I do not get the error. I've looked online for a couple hours and can not seem to find clear documentation.

Thanks,
Carolyn

Pyenv deactivate not working

I am using Python 3.4.1 and installed pyenv manually and via homebrew on my Mac OSX running v 10.9.3. After creating a virtualenv and then activating it, which all works. I have a problem with deactivating. When I run 'pyenv deactivate' nothing happens and my shell still shows me as being in the virtualenv.

Any ideas to fix this? Thanks. If I do 'pyenv shell --unset' while in a virtualenv works to 'deactivate'.

Running pyenv deactivate in debug. Hiding my directory name from web scrapers.

++ [pyenv:15] type -p greadlink readlink
++ [pyenv:15] head -1

  • [pyenv:15] READLINK=/usr/bin/readlink
  • [pyenv:16] '[' -z /usr/bin/readlink ']'
  • [pyenv:21] unset GREP_OPTIONS
  • [pyenv:41] '[' -z /Users/HIDDEN/.pyenv ']'
  • [pyenv:44] PYENV_ROOT=/Users/HIDDEN/.pyenv
  • [pyenv:46] export PYENV_ROOT
  • [pyenv:48] '[' -z '' ']'
    ++ [pyenv:49] pwd
  • [pyenv:49] PYENV_DIR=/Users/HIDDEN
  • [pyenv:58] export PYENV_DIR
  • [pyenv:61] shopt -s nullglob
    ++ [pyenv:63] abs_dirname /Users/HIDDEN/.pyenv/bin/pyenv
    +++ [pyenv:28] pwd
    ++ [pyenv:28] local cwd=/Users/HIDDEN
    ++ [pyenv:29] local path=/Users/HIDDEN/.pyenv/bin/pyenv
    ++ [pyenv:31] '[' -n /Users/HIDDEN/.pyenv/bin/pyenv ']'
    ++ [pyenv:32] cd /Users/HIDDEN/.pyenv/bin
    ++ [pyenv:33] local name=pyenv
    +++ [pyenv:34] resolve_link pyenv
    +++ [pyenv:24] /usr/bin/readlink pyenv
    ++ [pyenv:34] path=../libexec/pyenv
    ++ [pyenv:31] '[' -n ../libexec/pyenv ']'
    ++ [pyenv:32] cd ../libexec
    ++ [pyenv:33] local name=pyenv
    +++ [pyenv:34] resolve_link pyenv
    +++ [pyenv:24] /usr/bin/readlink pyenv
    +++ [pyenv:34] true
    ++ [pyenv:34] path=
    ++ [pyenv:31] '[' -n '' ']'
    ++ [pyenv:37] pwd
    ++ [pyenv:38] cd /Users/HIDDEN
  • [pyenv:63] bin_path=/Users/HIDDEN/.pyenv/libexec
  • [pyenv:64] for plugin_bin in '"${PYENV_ROOT}/plugins/"*/bin'
  • [pyenv:65] bin_path=/Users/HIDDEN/.pyenv/libexec:/Users/HIDDEN/.pyenv/plugins/pyenv-virtualenv/bin
  • [pyenv:64] for plugin_bin in '"${PYENV_ROOT}/plugins/"*/bin'
  • [pyenv:65] bin_path=/Users/HIDDEN/.pyenv/libexec:/Users/HIDDEN/.pyenv/plugins/pyenv-virtualenv/bin:/Users/HIDDEN/.pyenv/plugins/python-build/bin
  • [pyenv:67] export PATH=/Users/HIDDEN/.pyenv/libexec:/Users/HIDDEN/.pyenv/plugins/pyenv-virtualenv/bin:/Users/HIDDEN/.pyenv/plugins/python-build/bin:/Users/HIDDEN/.pyenv/versions/test/bin:/Users/HIDDEN/.pyenv/shims:/Users/HIDDEN/.pyenv/bin:/Users/HIDDEN/.rvm/gems/ruby-2.1.2/bin:/Users/HIDDEN/.rvm/gems/ruby-2.1.2@global/bin:/Users/HIDDEN/.rvm/rubies/ruby-2.1.2/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/HIDDEN/.rvm/bin
  • [pyenv:67] PATH=/Users/HIDDEN/.pyenv/libexec:/Users/HIDDEN/.pyenv/plugins/pyenv-virtualenv/bin:/Users/HIDDEN/.pyenv/plugins/python-build/bin:/Users/HIDDEN/.pyenv/versions/test/bin:/Users/HIDDEN/.pyenv/shims:/Users/HIDDEN/.pyenv/bin:/Users/HIDDEN/.rvm/gems/ruby-2.1.2/bin:/Users/HIDDEN/.rvm/gems/ruby-2.1.2@global/bin:/Users/HIDDEN/.rvm/rubies/ruby-2.1.2/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/HIDDEN/.rvm/bin
  • [pyenv:69] hook_path=:/Users/HIDDEN/.pyenv/pyenv.d:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib/pyenv/hooks
  • [pyenv:73] export PYENV_HOOK_PATH=:/Users/HIDDEN/.pyenv/pyenv.d:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib/pyenv/hooks
  • [pyenv:73] PYENV_HOOK_PATH=:/Users/HIDDEN/.pyenv/pyenv.d:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib/pyenv/hooks
  • [pyenv:75] shopt -u nullglob
  • [pyenv:78] command=sh-deactivate
  • [pyenv:79] case "$command" in
    ++ [pyenv:87] command -v pyenv-sh-deactivate
  • [pyenv:87] command_path=/Users/HIDDEN/.pyenv/plugins/pyenv-virtualenv/bin/pyenv-sh-deactivate
  • [pyenv:88] '[' -z /Users/HIDDEN/.pyenv/plugins/pyenv-virtualenv/bin/pyenv-sh-deactivate ']'
  • [pyenv:93] shift 1
  • [pyenv:94] exec /Users/HIDDEN/.pyenv/plugins/pyenv-virtualenv/bin/pyenv-sh-deactivate
    ++ [pyenv-sh-deactivate:12] basename bash
  • [pyenv-sh-deactivate:12] shell=bash
  • [pyenv-sh-deactivate:13] case "$shell" in
  • [pyenv-sh-deactivate:15] echo 'declare -f deactivate 1>/dev/null 2>&1 && deactivate;'
  • [pyenv-sh-deactivate:18] '[' -z 1 ']'

Add 'VIRTUAL_ENV' environment variable for jedi to add site-packages into PATH

Hi there,

I found there is no 'VIRTUAL_ENV' environment variable which is used by jedi library
https://github.com/davidhalter/jedi/blob/master/jedi/evaluate/sys_path.py#L13

Could you prefer to add this one ? For example, I have a virtualenv in ~/.pyenv/versions/web/. The VIRTUAL_ENV will be ~/.pyenv/versions/web/, so that ~/.pyenv/versions/web/lib/python2.7/site-packages will be added into sys.path when jedi loads. Jedi will autocomplete the packages in that folder.

My environment : pyenv-virtualenv + jedi-vim

Deleting Virtual Environments

Hi @yyuu! Love the tool, one question. Is the only way to remove a venv created by pyenv virtualenv by deleting the folder in ~/.pyenv/versions?

pip list issue?

So I have a local python version within a folder (set by pyenv local 2.7.8) and I also have created a virtualenv using this command: pyenv virtualenv 2.7.8 venv278. (not active at the moment). Now I do pip list and sure enough I get the right result. Now I activate the virtualenv like so: pyenv activate venv278. and pip install a package (let's say django). while the virtualenv is still active I do pip list, and I see django package in the list. So far, so good. But when I deactivate the virtualenv and do pip list again, I can still see django in the list. Which I think is wrong. However when I restart the terminal and go to that directory again and do pip list (with virtualenv NOT activated yet) I get the correct result, i.e. the list without django!

I'm running mac os x (version 10.9.4) and installed pyenv through homebrew.

Commands not available when using `--system-site-packages`

I am trying to setup a virtualenv with --system-site-packages to use compiled/pre-built packages, and noticed that e.g. ipython fails to run with:

% pyenv virtualenv --system-site-packages 3.4.2 paperwork3
...
% ipython
pyenv: ipython: command not found

The `ipython' command exists in these Python versions:
...

Trying to install it skips it, because it appears to be installed already.

Could pyenv somehow handle this, especially after trying to (re-)install it?

pyenv-virtualenv slows down zsh considerably

If eval "$(pyenv virtualenv-init -)" is in my zshenv, every time a command finishes there is a delay of about a second. Even hitting the enter key to cause another prompt without entering a command is slow.

Judging by what init does to the shell, perhaps this is because this command is slow:
pyenv activate --no-error --verbose

I do not have PYENV_ACTIVATE set, so that branch of the init logic would be hit.

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.