CentOS --python环境安装

1.CentOS 7系统 Pyenv 管理 Python环境

Pyenv 是一款解决 Python 多版本环境使用的管理工具。通过 pyenv 我们可以同时编译安装部署多个 Python 环境,方便多 python 版本开发调试项目。

①通过安装git方式安装Pyenv
[python@localhost ~]$ su -l root
Password: 
Last login: Tue Apr  2 16:07:47 CST 2019 on pts/0
[root@localhost ~]# yum install git
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.cn99.com
 * updates: mirrors.cn99.com
Package git-1.8.3.1-20.el7.x86_64 already installed and latest version
Nothing to do
[root@localhost ~]# exit
logout
[python@localhost ~]$ git clone https://github.com/pyenv/pyenv.git .pyenv
Cloning into '.pyenv'...
remote: Enumerating objects: 81, done.
remote: Counting objects: 100% (81/81), done.
remote: Compressing objects: 100% (45/45), done.
remote: Total 16818 (delta 37), reused 61 (delta 28), pack-reused 16737
Receiving objects: 100% (16818/16818), 3.29 MiB | 463.00 KiB/s, done.
Resolving deltas: 100% (11379/11379), done.
[python@localhost ~]$ ls -adl .pyenv
drwxrwxr-x. 11 python python 4096 Apr  2 16:13 .pyenv
[python@localhost ~]$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
[python@localhost ~]$
[python@localhost ~]$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
[python@localhost ~]$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bashrc
[python@localhost ~]$ pyenv
bash: pyenv: command not found...
[python@localhost ~]$
[python@localhost ~]$ source .bashrc 
[python@localhost ~]$ pyenv
pyenv 1.2.9-35-gb610909
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
②通过pyenv编译安装Python环境

pyenv install --list列出当前pyenv工具支持的python版本。

[root@VM-4-2-centos ~]# pyenv install --list

安装python版本

[root@VM-4-2-centos ~]# pyenv install -v 3.8.5

显示python安装版本

[root@VM-4-2-centos ~]# pyenv versions

指定python版本

[root@VM-4-2-centos ~]# pyenv shell 3.8.5
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值