1.インストール
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#update と 必要なパッケージ入れる | |
sudo yum update -y | |
sudo yum install -y gcc gcc-c++ make git openssl-devel bzip2-devel zlib-devel readline-devel sqlite-devel bzip2 sqlite curl | |
#ubuntuの場合 | |
#初期UPDATE | |
#sudo apt-get update | |
#sudo apt-get upgrade | |
#必要なライブラリインストール | |
#sudo apt-get install -y git gcc make openssl build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils libgtk2.0-dev pkg-config | |
#pyenvのインストール | |
git clone git://github.com/yyuu/pyenv.git ~/.pyenv | |
#環境設定 | |
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc | |
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc | |
echo 'eval "$(pyenv init -)"' >> ~/.bashrc | |
exec $SHELL -l | |
#pyenv-virtualenvのインストール+環境設定 | |
git clone https://github.com/pyenv/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv | |
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc | |
exec $SHELL -l |
2.チェックとちょこっと設定
#切り替え可能なバージョンチェック
[ec2-user@ip-10-0-0-174 ~]$ pyenv versions
* system (set by /home/ec2-user/.pyenv/version)
#インストール可能なPythonバージョンを確認
#インストール可能なPythonバージョンを確認
[ec2-user@ip-10-0-0-174 ~]$ pyenv install -l
Available versions:
2.1.3
2.2.3
2.3.7
2.4
2.4.1
2.4.2
#新しいPythonのバージョンをインストール
#新しいPythonのバージョンをインストール
[ec2-user@ip-10-0-0-174 ~]$ pyenv install 2.7.13
Downloading Python-2.7.13.tar.xz...
-> https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tar.xz
Installing Python-2.7.13...
Installed Python-2.7.13 to /home/ec2-user/.pyenv/versions/2.7.13
#2.7.13が追加された。
[ec2-user@ip-10-0-0-174 ~]$ pyenv versions
* system (set by /home/ec2-user/.pyenv/version)
2.7.13
#2.7.13をベースに、"testpy"という環境を構築する
#2.7.13をベースに、"testpy"という環境を構築する
[ec2-user@ip-10-0-0-174 ~]$ pyenv virtualenv 2.7.13 testpy
Collecting virtualenv
Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB)
100% |████████████████████████████████| 1.8MB 638kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-15.1.0
New python executable in /home/ec2-user/.pyenv/versions/2.7.13/envs/testpy/bin/python2.7
Also creating executable in /home/ec2-user/.pyenv/versions/2.7.13/envs/testpy/bin/python
Installing setuptools, pip, wheel...done.
Requirement already satisfied: setuptools in /home/ec2-user/.pyenv/versions/2.7.13/envs/testpy/lib/python2.7/site-packages
Requirement already satisfied: pip in /home/ec2-user/.pyenv/versions/2.7.13/envs/testpy/lib/python2.7/site-packages
#"testpy"が追加された
#"testpy"が追加された
[ec2-user@ip-10-0-0-174 ~]$ pyenv versions
* system (set by /home/ec2-user/.pyenv/version)
2.7.13
2.7.13/envs/testpy
testpy
#開発用のディレクトリ"pyproject"のPython環境を"testpy"に変更する
バージョン2.7.13へと変更された。
#開発用のディレクトリ"pyproject"のPython環境を"testpy"に変更する
[ec2-user@ip-10-0-0-174 ~]$ cd pyproject/
#今のバージョンは、2.7.5だが。。
#今のバージョンは、2.7.5だが。。
[ec2-user@ip-10-0-0-174 pyproject]$ python -V
Python 2.7.5
#Pyenvで変更すると
#Pyenvで変更すると
[ec2-user@ip-10-0-0-174 pyproject]$ pyenv local testpy
(testpy) [ec2-user@ip-10-0-0-174 pyproject]$ python -V
Python 2.7.13
バージョン2.7.13へと変更された。
0 件のコメント:
コメントを投稿