[英]Pyenv not auto activating
I have pyenv installed in my environment and up to this weekend (when I installed 'Kivy') my pyenv/local setup has been working fine. 我在我的环境中安装了pyenv,直到本周末(当我安装'Kivy'时)我的pyenv / local设置工作正常。 But now when I go to my various python project directories, pyenv does not automatically activate the right python version properly. 但是现在当我进入各种python项目目录时,pyenv不会自动正确地激活正确的python版本。
Eg 例如
I create an environment using pyenv like this, 我使用像这样的pyenv创建一个环境,
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. 我让去到一个目录叫work
,并有.python-version
与文本文件work
作为唯一的内容。
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
. Pyenv检测到我的环境是使用这个文件work
但我的python版本不是python 3.3.2
而是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. 出于某种原因,发生了一些事情,并且我的所有pyenv虚拟环境都使用2.7.9
,而不是使用它们创建的python版本。
When I run which python
I get, 当我运行which python
,
/opt/boxen/homebrew/bin/python
when I go to the pyenv version directory and run 当我去pyenv版本目录并运行
$ 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). 但是,如果我运行pyenv activate
我的python版本切换到python 3.3.2
(或给定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). 问题是,如何让pyenv像以前一样自动激活环境的python版本(在我做某事之前打破它)。
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. 这听起来像的,因为which python
不说这是垫片,你没有的bin /垫片路径先在你的PATH
ENVVAR。 Add these lines to your shell startup script, and make sure they're at the end , after any other path manipulations. 将这些行添加到shell启动脚本中,并确保它们在任何其他路径操作之后结束 。
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. eval
行做了一些额外的shell .pyenv/shims
我想添加.pyenv/shims
目录...检查一下echo $PATH
也许。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.