Pyenv-virtualenv: Auto activation does not work

Created on 11 Feb 2016  路  8Comments  路  Source: pyenv/pyenv-virtualenv

Using pyenv 20160202

I have a directory and cd into it; then run
pyenv local 2.7.11

Which creates the version I wish to use:

$ python -V
Python 2.7.11

Creating virtualenv:
pyenv virtualenv 2.7.11 directoryname

It seems to generate some output.
When I go cd .. and cd <directoryname> the env does not get activated.

I have to manually go:

$ pyenv activate directoryname

This is irritating; will this be fixed soon?

Most helpful comment

Remember to have this in your profile:

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

That reads .python_version when you change into a directory (created using local).

I set my env to the version of pyenv (in my case I set it to 2.7.11). but I should've set it to the name of the virtualenv. Steps:

pyenv virtualenv 3.5.2 fubar

# wrong
pyenv local 3.5.2

# correct
pyenv local fubar

All 8 comments

2.7.11 isn't a virtualenv.

I do not follow: your readme states to create it this way:

pyenv virtualenv 2.7.10 my-virtual-env-2.7.10

What does the contents of the .python_version need to be?

Ah, I have to set the local to the virtualenv, thanks!

@Tjorriemorrie I'm sorry but this isn't clear to me either, could you elaborate on that? What exactly does the setup needs to be in order to auto-activate the virtualenv?

Thanks for the help!

Remember to have this in your profile:

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

That reads .python_version when you change into a directory (created using local).

I set my env to the version of pyenv (in my case I set it to 2.7.11). but I should've set it to the name of the virtualenv. Steps:

pyenv virtualenv 3.5.2 fubar

# wrong
pyenv local 3.5.2

# correct
pyenv local fubar

Oh yees! now we're talking!

Thanks for the help @Tjorriemorrie! Have a nice one!

Thanks, I see the docs do not make this clear, https://github.com/pyenv/pyenv/blob/master/COMMANDS.

Thanks to whoever figured this out.

Got tripped on this issue's subject. I had set a default version in my profile export PYENV_VERSION=3.6.5. This prevents the virtual-env from changing when cd'ing to a directory that has a local config.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

melentye picture melentye  路  7Comments

rghamilton3 picture rghamilton3  路  11Comments

Insoleet picture Insoleet  路  3Comments

jackmaney picture jackmaney  路  7Comments

oblitum picture oblitum  路  11Comments