Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
18
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

updated at

CentOS7にPyenvとPython3系をインストール

CentOSにPython3系が入っていないので、やり方をメモ。
ついでにpyenvも入れてバージョンを切り替えられるようにした。

環境

OS・ミドルウェア バージョン
CentOS CentOS Linux release 7.3.1611 (Core)
Git git version 2.13.2
Vim version 8.0.692
Python 3.6.2

手順

  1. ライブラリのインストール

    # yum -y install gcc zlib-devel bzip2 bzip2-devel readline readline-devel sqlite sqlite-devel openssl openssl-devel
    
  2. pyenv installerの起動

    # curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
    
  3. 必要に応じてPATHの記述

    # vi ~/.bash_profile
    

    以下の内容を記載

    export PATH="~/.pyenv/bin:$PATH"
    eval "$(pyenv init -)"
    eval "$(pyenv virtualenv-init -)"
    
    # source ~/.bash_profile
    # pyenv
    pyenv 1.1.3
    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 
    
  4. Python3系のインストール

    # pyenv install 3.6.2
    
  5. インストールしたPythonを使用するように設定

    # pyenv global 3.6.2
    

これでインストールしたPythonが使用できる

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
18
Help us understand the problem. What are the problem?