15
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2017-07-19

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が使用できる

15
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?