Linux system installation pyenv concise tutorial

It is recommended to pay attention to the blogger's WeChat public account Android security project . The WeChat public account focuses on the security protection and reverse analysis of Android applications, sharing various security attack and defense methods, Hook technology, ARM compilation and other Android-related knowledge

Preconditions

  • git
  • Kali 2022 / Ubuntu 16.04

installation steps

1. Clone pyenv from the remote repository

Clone pyenv with the following command:

git clone https://github.com/yyuu/pyenv.git ~/.pyenv

2. Configure environment variables

Use the command to configure environment variables:

sudo vim /etc/profile

Add the following attributes inside the text:

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

3. Using environment variables

Use the source command to re-execute the configuration file modified in the previous step:

source /etc/profile

At this point, pyenv is installed.

You can use the following command to check the installed version of pyenv:

[root@server1 local]# pyenv -v
pyenv 2.3.2

4. Download the required Python version

View available Python versions with the list command

pyenv install --list

The result is as follows:

Available versions:
  2.1.3
  2.2.3
  2.3.7
  2.4.0
  2.4.1
  ...
pyenv install 3.9.0

At this time, the download may be slow, and the buffer directory downloaded by pyenv is ~/.pyenv/cache. Change to this directory, if not cachethen:

sudo mkdir cache
// 这里根据自己需要的下载链接替换
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz 
pyenv install 3.9.0

insert image description here

Check the installed Python version:

pyenv versions
// 显示:(*号表示当前使用的版本)
* system (set by /home/iroot/.pyenv/version)
  3.9.0

Switch to the Python version you need:

pyenv global 3.9.0
pyenv versions
// 显示:
  system
* 3.9.0 (set by /home/iroot/.pyenv/version)

The above means that you have successfully switched to the Python version you need.

5. View help

pyenv help
// 显示:
Usage: pyenv <command> [<args>]

Some useful pyenv commands are:
   commands    List all available pyenv commands
   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
   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 a specific Python version
   --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
   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

Guess you like

Origin blog.csdn.net/HongHua_bai/article/details/128501930