[LINUX] Studying Python Part.1 Creating an environment
Introduction
I'm going to use Python for work, so I'll leave it as a memo.
All the information is already on many sites,
I will use this place because it is easy to follow by writing an article.
Environment creation
Since we are planning to adopt python 3.5.0, we will start from creating this environment.
OS installation
Create an environment with Amazon Web Service that can be used free of charge for one year.
Select and create an Amazon Linux AMI that is free and easy to build.
Please refer to another article for this.
First, create an instance of EC2
After creating the instance
- Network & Security
- Select Elastic IP
- Assign a new address to get a public IP address
- Perform the address association in the "Action" menu
- Set and associate the created instance with a private IP address
- This is a measure to prevent the global IP address from changing when the server is restarted.
- Remote login with SSH
- Log in with SSH (in my case, teraterm) using the pem file downloaded when creating the instance
- Log in as the ec2-user user
- Just in case, change the password with
# passwd ec2-user
- Change root password `` `# sudo su -``` to root
- Change root password with
# passwd
- Log out once
- Login with
`# su --`
- yum update
- Update your system with `` `# yum update -y```
Create a python environment
It was quite difficult. .. ..
But once you know it, it's easy.
Prerequisites:
Use python 3.5.0 with ec2-user
Manage python with pyenv
- Pyenv is a tool for managing the python environment.
- Python can be used by switching between multiple versions within the same OS.
- Install the required functions for pyenv
- Become the root user
- Install what you need with yum
# yum install mlocate openssl-devel bzip2-devel zlib-devel bzip2 bzip2-devel readline-devel sqlite3 sqlite-devel openssl-devel gcc gcc-c++ git
- Return to the original user with `` `# exit```
- Install pyenv
# git clone https://github.com/yyuu/pyenv.git ~ / .pyenv
- Add the following to your profile with `` `# vi .bash_profile```
export PYENV_ROOT="{HOME}/.pyenv"
if [ -d "{PYENV_ROOT}" ]; then
export PATH={PYENV_ROOT}/bin:PATH
eval "$(pyenv init -)"
fi
- Read with
# source ~ / .bash_profile
- Install python `` `# pyenv install 3.5.0```
- Check the current status with `` `# pyenv versions ```
* system
3.5.0 (set by /home/ec2-user/.pyenv/version)
- Change the version of python `` `# pyenv global 3.5.0```
- Check the current status again with
# pyenv versions
system
* 3.5.0 (set by /home/ec2-user/.pyenv/version)
- Confirm that the version has been changed
- Check the version of python itself
# python -V
Python 3.5.0
- Log out remotely and log in again to reconfirm the python version.
- If there is no problem, this completes the environment creation
At the end
There are many ways to install it, but I think this is the easiest.