前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python之pyenv安装 and i

python之pyenv安装 and i

作者头像
py3study
发布2020-01-08 15:59:39
5180
发布2020-01-08 15:59:39
举报
文章被收录于专栏:python3python3

pyenv可以很好的实现Python的多版本共存。

需要使用新版本Python的相关功能,但是又不想要影响到系统自带的Python,这个时候就需要实现Python的多版本共存。

安装依赖:

代码语言:javascript
复制
yum -y install gcc gcc-c++ make git patch openssl-devel zlib-devel readline-devel sqlite-devel bzip2-devel

安装pyenv:

代码语言:javascript
复制
curl https://raw.github.com/yyuu/pyenv-installer/master/bin/pyenv-installer |bash

配置环境变量方法一:

代码语言:javascript
复制
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
exec $SHELL -l

配置环境变量方法二:

将环境变量追加到 >> /etc/profile.d/pyenv.sh

pyenv基本使用:

代码语言:javascript
复制
[root@node1 桌面]# 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/yyuu/pyenv#readme
代码语言:javascript
复制
pyenv versions 查看已安装版本
pyenv install 2.7.5 
pyenv uninstall 2.7.5
pyenv local 2.7.5 设置本地的特定目录的Python版本
pyenv rehash 重建环境变量
pyenv global 2.7.5 设置全局的python版本

ipython 是一个 python 的交互式 shell,比默认的python shell 好用得多,支持变量自动补全,自动缩进,支持 bash shell 命令,内置了许多很有用的功能和函数。

安装ipython

代码语言:javascript
复制
pip install ipython

使用ipython

代码语言:javascript
复制
[root@node1 ~]# ipython
pyenv: ipython: command not found
The `ipython' command exists in these Python versions:
  2.7.5
[root@node1 ~]# pyenv versions
* system (set by /root/.pyenv/version)
  2.7.5
[root@node1 ~]# pyenv local 2.7.5
[root@node1 ~]# pyenv rehash
[root@node1 ~]# ipython
Python 2.7.5 (default, Apr  8 2014, 22:28:25)
Type "copyright", "credits" or "license" for more information.
IPython 2.0.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
In [1]: import os
In [2]: os.sys                 #TAB补全
os.sys            os.sysconf        os.sysconf_names  os.system        
In [2]: os.sys     
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-09-08 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档