Windows上安装pyenv,以及pyenv切换环境不生效的问题

1. pyenv安装

重装了系统,之前的系统卡死了。

于是也重装了pyenv, 在官网上看到有powershell命令一键安装:

Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1" -OutFile "./install-pyenv-win.ps1"; &"./install-pyenv-win.ps1"

但是等了半天也没有下载成功,国内网络环境棒棒哒。
看到gitee上有克隆项目,于是将链接同步使用国内的。

https://gitcode.com/mirrors%2Fpyenv-win/pyenv-win/blob/master/pyenv-win%2Finstall-pyenv-win.ps1

将上面脚本链接换为下面的,这次可以成功下载了,但是实际安装提示脚本错误.

PS C:\Users\Miste> Invoke-WebRequest -UseBasicParsing -Uri "https://gitcode.com/mirrors%2Fpyenv-win/pyenv-win/tree/master/pyenv-win/install-pyenv-win.ps1" -OutFile "./install-pyenv-win.ps1"; &"./install-pyenv-win.ps1"
所在位置 C:\Users\Miste\install-pyenv-win.ps1:7 字符: 10
+     <!-- <meta name="referrer" content="no-referrer"> -->
+          ~
“<”运算符是为将来使用而保留的。
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : RedirectionNotSupported

仔细看看下载的文件,里面居然是html,是TM一个网页文件。
所以只能强行去复制代码了(浏览器打开链接并复制源码到本地)
然后再使用powershell执行脚本,至此,安装完成。

2. pyenv使用

安装完成了,首先安装个python版本,执行:

pyenv install 3.11.4

安装完成后设置为全局使用:

pyenv global 3.11.4

然后重新打开cmd窗口,查看python版本:

C:\Users\Miste>python -V
Python 2.7.18

C:\Users\Miste>

居然没生效,于是又设置了几次,但是还是没有生效。MD
网上找找资料,最后看到一段话:

In windows NT, the PATH variable is a combined result of the system and user variables:

The Path is constructed from the system path, which can be viewed in the System Environment Variables field in the System dialog box. The User path is appended to the system path

Shims PATH are defined in the user variables, so make sure your host python interpreter path is not defined in your system path

意思是windows环境变量中有配置的python版本,则pyenv将不生效。所以我去看了下

右键我的电脑>属性>高级系统设置>环境变量

这里检查下有没有自己定义python路径,有的话删除掉,我这里就是这里有定义一个2.7.18的,删除掉后就好了。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值