pipPython运维日记

一 Python 工作环境管理

1.1 使用 pyenv 管理不同的Python 版本

克隆项目安装

git clone https://github.com/yyuu/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
source ~/.bash_profile 

# 验证
[root@test1 ~]# pyenv --help
Usage: pyenv <command> [<args>]

Some useful pyenv commands are:
   commands    List all available pyenv commands
   local       Set or show the local application-specific Python version
   global      Set or show the global Python version
   shell       Set or show the shell-specific Python version
   install     Install a Python version using python-build
   uninstall   Uninstall a specific Python version
   rehash      Rehash pyenv shims (run this after installing executables)
   version     Show the current Python version and its origin
   versions    List all Python versions available to pyenv
   which       Display the full path to an executable
   whence      List all Python versions that contain the given executable

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

  日常管理

 # 安装所需依赖
yum -y install zlib*  libffi-devel openssl-devel 

查看 pyenv支持的puthon版本
pyenv install --list

安装 python 3.7.3
pyenv install -v 3.7.3

查看 所有 安装的 Python版本
pyenv versions

指定切换 Python版本
pyenv global 3.7.3

删除 指定的 Python版本
pyenv uninstall 3.7.3

pip 管理

yum install -y python-pip

pip install -U pip

# pip 子命令

install            # 安装软件包
download           # 下载安装包
uninstall          # 卸载安装包
freeze             # 按照 requirements 格式输出安装包, pip install -r requirements.txt 直接安装
list               # 列出当前系统中的安装包
show               # 查看 安装包的信息,包括版本,依赖,许可证,作者,主页等信息
check              # 检查 安装包的依赖关系
search             # 查找 安装包

Python 启动服务器

# python -m http.server

  

  

原文地址:https://www.cnblogs.com/yanshicheng/p/10654691.html