python

关注公众号 jb51net

关闭
首页 > 脚本专栏 > python > 版本管理器Pyenv-win安装

Python版本管理器之Pyenv-win介绍与安装方法详解

作者:小猿搬码

pyenv-win是pyenv的Windows版本,是一个Python版本管理工具,使用户可以轻松在多个版本之间切换,这篇文章主要介绍了Python版本管理器之Pyenv-win介绍与安装方法的相关资料,需要的朋友可以参考下

1. Pyenv-win

1. 官网

https://pyenv-win.github.io/pyenv-win/#introduction

github:https://github.com/pyenv-win/pyenv-win

2.Pyenv

gitHub: https://github.com/pyenv/pyenv

Pyenv for Python 是一个很棒的工具,但与 Ruby 开发的 rbenv 一样,它不直接支持 Windows。经过一些研究和 python 开发人员的反馈,我发现他们希望为 Windows 系统提供类似的功能。

3. pyenv-win是什么?

pyenv 的 Windows 版本。Pyenv 是一个简单的 Python 版本管理工具。它使您可以轻松地在多个 Python 版本之间切换。它简单、不引人注目,并遵循 UNIX 的传统,即只做一件事的单一用途工具。

该项目是从 rbenv-win 分叉出来的,并针对 pyenv 进行了修改。

2. 安装

1. 快速安装

​ 如下图

> python -c "import sys; print(sys.executable)"
\path\to\.pyenv\pyenv-win\versions\<version>\python.exe

如下图

2. pyenv-win 命令

   commands     List all available pyenv commands
   local        Set or show the local application-specific Python version
   latest       Print the latest installed or known version with the given prefix
   global       Set or show the global Python version
   shell        Set or show the shell-specific Python version
   install      Install 1 or more versions of Python
   uninstall    Uninstall 1 or more versions of Python
   update       Update the cached version DB
   rehash       Rehash pyenv shims (run this after switching Python versions)
   vname        Show the current Python version
   version      Show the current Python version and its origin
   version-name Show the current Python version
   versions     List all Python versions available to pyenv
   exec         Runs an executable by first preparing PATH so that the selected 
                Python version's `bin' directory is at the front
   which        Display the full path to an executable
   whence       List all Python versions that contain the given executable

3. 用法

在这里插入图片描述

4. 更新 pyenv

5. 安装时Powershell禁止运行脚本

1. 安装pyenv-win出差

2. 解决方式

原因是Windows新的权限执行策略改变,休要在PowerShell里面执行命令:

Get-ExecutionPolicy
# 输出的是:Restricted

若要更改执行策略,以管理员身份打开PowerShell,然后使用以下命令之一设置执行策略

Set-ExecutionPolicy RemoteSigned

具体提如下图

6.关于PowerShell运行脚本的方法

在Windows操作系统中,PowerShell默认的执行策略可能会限制用户运行脚本,这是一种安全措施,用于防止未经授权的脚本执行,可能对系统造成潜在的安全风险。如果用户确信要运行的脚本是安全的,可以通过更改执行策略来允许脚本执行。

更改执行策略的步骤

首先,需要了解PowerShell中的执行策略级别。执行策略有几种级别,包括:

要查看当前的执行策略,可以在PowerShell中输入以下命令:

Get-ExecutionPolicy

若要更改执行策略,以管理员身份打开PowerShell,然后使用以下命令之一设置执行策略:

Set-ExecutionPolicy RemoteSigned

或者,如果需要,也可以选择Unrestricted策略,但请注意这样做可能会增加安全风险:

Set-ExecutionPolicy Unrestricted

执行以上命令时,系统会提示确认更改。输入Y并回车以确认。

更改执行策略可能会影响系统的安全性。在更改执行策略之前,请确保了解可能的安全影响。如果在组织中使用PowerShell,可能需要咨询IT部门,因为组织可能有自己的安全策略。

总结

到此这篇关于Python版本管理器之Pyenv-win介绍与安装方法的文章就介绍到这了,更多相关版本管理器Pyenv-win安装内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

您可能感兴趣的文章:
阅读全文