Kali安装pyenv

pyenv 可让您轻松地在多个 Python 版本之间切换

安装依赖

apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev

安装pyenv

┌──(root㉿MYsec)-[/home/hirak0]
└─# curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2827  100  2827    0     0   1577      0  0:00:01  0:00:01 --:--:--  1577
正克隆到 '/root/.pyenv'...
remote: Enumerating objects: 1243, done.
remote: Counting objects: 100% (1243/1243), done.
remote: Compressing objects: 100% (690/690), done.
remote: Total 1243 (delta 727), reused 708 (delta 420), pack-reused 0
接收对象中: 100% (1243/1243), 618.78 KiB | 1.05 MiB/s, 完成.
处理 delta 中: 100% (727/727), 完成.
正克隆到 '/root/.pyenv/plugins/pyenv-doctor'...
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 11 (delta 1), reused 5 (delta 0), pack-reused 0
接收对象中: 100% (11/11), 38.72 KiB | 167.00 KiB/s, 完成.
处理 delta 中: 100% (1/1), 完成.
正克隆到 '/root/.pyenv/plugins/pyenv-update'...
remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 10 (delta 1), reused 5 (delta 0), pack-reused 0
接收对象中: 100% (10/10), 完成.
处理 delta 中: 100% (1/1), 完成.
正克隆到 '/root/.pyenv/plugins/pyenv-virtualenv'...
remote: Enumerating objects: 63, done.
remote: Counting objects: 100% (63/63), done.
remote: Compressing objects: 100% (56/56), done.
remote: Total 63 (delta 11), reused 29 (delta 0), pack-reused 0
接收对象中: 100% (63/63), 41.13 KiB | 351.00 KiB/s, 完成.
处理 delta 中: 100% (11/11), 完成.

WARNING: seems you still have not added 'pyenv' to the load path.

# Load pyenv automatically by appending
# the following to 
# ~/.bash_profile if it exists, otherwise ~/.profile (for login shells)
# and ~/.bashrc (for interactive shells) :

export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

# Restart your shell for the changes to take effect.

# Load pyenv-virtualenv automatically by adding
# the following to ~/.bashrc:

eval "$(pyenv virtualenv-init -)"

配置相关Path

把以下内容写入 ~/.bashrc 并重启

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc

然后执行下面的命令

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
echo 'eval "$(pyenv init -)"' >> ~/.profile
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc

执行下面的命令刷新

exec "$SHELL"

验证是否安装成功

pyenv -h 

出现以下内容说明安装完成

┌──(root㉿MYsec)-[/home/hirak0]
└─# pyenv -h 
Usage: pyenv <command> [<args>]

Some useful pyenv commands are:
   activate    Activate virtual environment
   commands    List all available pyenv commands
   deactivate   Deactivate virtual environment
   doctor      Verify pyenv installation and development tools to build pythons.
   exec        Run an executable with the selected Python version
   global      Set or show the global Python version(s)
   help        Display help for a command
   hooks       List hook scripts for a given pyenv command
   init        Configure the shell environment for pyenv
   install     Install a Python version using python-build
   latest      Print the latest installed or known version with the given prefix
   local       Set or show the local application-specific Python version(s)
   prefix      Display prefixes for Python versions
   rehash      Rehash pyenv shims (run this after installing executables)
   root        Display the root directory where versions and shims are kept
   shell       Set or show the shell-specific Python version
   shims       List existing pyenv shims
   uninstall   Uninstall Python versions
   update      Update pyenv, its plugins including the list of available versions
   --version   Display the version of pyenv
   version     Show the current Python version(s) and its origin
   version-file   Detect the file that sets the current pyenv version
   version-name   Show the current Python version
   version-origin   Explain how the current Python version is set
   versions    List all Python versions available to pyenv
   virtualenv   Create a Python virtualenv using the pyenv-virtualenv plugin
   virtualenv-delete   Uninstall a specific Python virtualenv
   virtualenv-init   Configure the shell environment for pyenv-virtualenv
   virtualenv-prefix   Display real_prefix for a Python virtualenv version
   virtualenvs   List all Python virtualenvs found in `$PYENV_ROOT/versions/*'.
   whence      List all Python versions that contain the given executable
   which       Display the full path to an executable

See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/pyenv/pyenv#readme  

pyenv命令说明

使用方法:pyenv <command> [<args>]
 
activate     激活虚拟环境
commands     列出所有可用的pyenv命令
deactivate     停用虚拟环境
doctor     验证pyenv安装以及构建Python所需的开发工具。
exec     使用所选的Python版本运行可执行文件
global     设置或显示全局Python版本
help     显示命令的帮助信息
hooks     列出给定pyenv命令的钩子脚本
init     配置shell环境以使用pyenv
install     使用python-build安装Python版本
latest     打印已安装或已知版本的最新版本(具有给定前缀)
local     设置或显示应用程序特定的本地Python版本
prefix     显示Python版本的前缀
rehash     重新生成pyenv shims(在安装可执行文件后运行此命令)
root     显示存储版本和shims的根目录
shell     设置或显示特定shell的Python版本
shims     列出现有的pyenv shims
uninstall     卸载Python版本
update     更新pyenv及其插件,包括可用版本列表
--version     显示pyenv的版本
version     显示当前Python版本及其来源
version-file     检测设置当前pyenv版本的文件
version-name     显示当前Python版本
version-origin     解释当前Python版本的设置方式
versions     列出pyenv可用的所有Python版本
virtualenv     使用pyenv-virtualenv插件创建Python虚拟环境
virtualenv-delete     卸载特定的Python虚拟环境
virtualenv-init     配置shell环境以使用pyenv-virtualenv
virtualenv-prefix       显示Python虚拟环境版本的real_prefix
virtualenvs     列出在$PYENV_ROOT/versions/*中找到的所有Python虚拟环境
whence         列出包含给定可执行文件的所有Python版本
which         显示可执行文件的完整路径
查看特定命令的信息,请使用pyenv help <command>。获取完整文档,请访问:https://github.com/pyenv/pyenv#readme

posted @ 2024-04-05 20:00  hirak0  阅读(133)  评论(0编辑  收藏  举报