Pyenv not auto activating

≡放荡痞女 提交于 2020-01-02 07:03:42

问题


I have pyenv installed in my environment and up to this weekend (when I installed 'Kivy') my pyenv/local setup has been working fine. But now when I go to my various python project directories, pyenv does not automatically activate the right python version properly.

E.g.

I create an environment using pyenv like this,

pyenv virtualenv 3.3.2 work

I make and go into a dir called work and have a .python-version file with the text work as the sole content.

Pyenv detects that my environment is work using this file but my python version is not python 3.3.2 instead it's 2.7.9.

For some reason, something happened, and all of my pyenv virtual environments use 2.7.9 as opposed to the python version they were created with.

When I run which python I get,

/opt/boxen/homebrew/bin/python

when I go to the pyenv version directory and run

$ cat pyvenv.cfg                                                                                                                                                                                           
home = /opt/boxen/pyenv/versions/3.3.2/bin
include-system-site-packages = false 
version = 3.3.2

However, if I run pyenv activate I my python version switches to python 3.3.2 (or the appropriate version for a given env).

Question is, how do I get pyenv to auto activate the environment's python version as it did before (before I did something to break it).


回答1:


It sounds like, because of which python not saying it's the shim, you don't have the bin/shims path first in your PATH envvar. Add these lines to your shell startup script, and make sure they're at the end, after any other path manipulations.

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

The eval line does some additional shell monkeying I think to add the .pyenv/shims directory...check that with an echo $PATH maybe.



来源:https://stackoverflow.com/questions/28544763/pyenv-not-auto-activating

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!