Pyenv无法自动激活 [英] Pyenv not auto activating

查看:124
本文介绍了Pyenv无法自动激活的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的环境中已经安装了pyenv,直到本周末(当我安装"Kivy"时),我的pyenv/本地设置都可以正常运行.但是现在当我进入各种python项目目录时,pyenv不会自动正确地激活正确的python版本.

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.

例如

我像这样使用pyenv创建环境,

I create an environment using pyenv like this,

pyenv virtualenv 3.3.2 work

我制作并进入一个名为work的目录,并有一个.python-version文件,其中文本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使用此文件检测到我的环境为work,但我的python版本不是python 3.3.2,而是2.7.9.

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虚拟环境都使用2.7.9而不是使用它们创建的python版本.

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.

当我运行which python时,我会得到

/opt/boxen/homebrew/bin/python

当我转到pyenv版本目录并运行

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

但是,如果我运行pyenv activate,我的python版本会切换到python 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像以前一样自动激活环境的python版本(在我做一些事情来破坏它之前).

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).

推荐答案

这听起来像是因为which python并不是说它是垫片,所以您没有bin/shims路径 first 在您的PATH envvar中.将这些行添加到您的Shell启动脚本中,并确保在进行任何其他路径操作之后它们位于 end 处.

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 -)"

eval行执行了一些其他的操作,我想添加.pyenv/shims目录...也许用echo $PATH进行检查.

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

这篇关于Pyenv无法自动激活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆