Run a batch of Python 2.7 with nohup on Amazon Linux AMI on EC2

I was researching about building a python environment with EC2 + Amazon Linux AMI, but I personally summarized it because the information was complicated and confused depending on the time.

It seems that python2.7 is the default in "Amazon Linux AMI 2015.03" as of the beginning of July 2015.

sudo yum -y update
python --version
> Python 2.7.9

However, when I tried to insert pandas with pip, I got an error such as something missing. It seems that you need to add make or gcc separately. Below you can find all the things that look like it.

sudo yum -y groupinstall "Development Tools"
sudo pip install pandas

By the way.

I tried to nohup, throw a batch, go home and check the situation at home, and when I run it with nohup as usual, even if I do tail -f, the print result does not come out.

nohup python my.py > out.log 2>&1 &

According to the following, if it is the default, it will be buffered until the end of processing, so it seems that you should add -u.

stackoverflow: Python - Nohup is not writing log to output file

With -u, it behaves as expected.

nohup python -u my.py > out.log 2>&1 &

For more information on options, see Home Reference )so.

-u


stdin, stdout,Forces stderr's buffer to be disabled. In the system involved, stdin, stdout,Put stderr into binary mode.

Recommended Posts

Run a batch of Python 2.7 with nohup on Amazon Linux AMI on EC2
Building a Python3 environment with Amazon Linux2
Install Python 3.8, Pip 3.8 on EC2 (Amazon Linux 2)
Memorandum of understanding when Python is run on EC2 with Apache
Install Python3 and Django on Amazon Linux (EC2) and run your web server
How to build a Python environment on amazon linux 2
Install Python Pillow on Amazon Linux
Run a Linux server on GCP
Install pyenv on EC2 (Amazon Linux)
[Note] Run Django on Amazon Linux 2
Run docker-compose on Amazon Linux2 on ARM64
Introduce Python 3.5.2 environment on Amazon Linux
Write a batch script with Python3.5 ~
Run cron on Amazon Linux (set on Linux)
Summary of installing PHP7.2 on EC2 (Amazon Linux 2) and setting php.ini
Create a Docker container image with JRE8 / JDK8 on Amazon Linux
I'll install Ruby on EC2 (Amazon Linux2) 2020
Run servo with Python on ESP32 (Windows)
A memo with Python2.7 and Python3 on CentOS
Map rent information on a map with python
[C] [python] Read with AquesTalk on Linux
Run Keycloak on Amazon Linux 2 without Docker
Run Python code on A2019 Community Edition
Run a Python web application with Docker
Run Linux on ARM architecture with QEMU
[Linux] Build a Docker environment with Amazon Linux 2
Procedure for building a kube environment on amazon linux2 (aws) ~ (with bonus)
Data integration from Python app on Linux to Amazon Redshift with ODBC
I measured the run queue wait time of a process on Linux
Rock-paper-scissors with Python Let's run on a Windows local server for beginners
How to run the practice code of the book "Creating a profitable AI with Python" on Google Colaboratory
A memo of a tutorial on running python on heroku
[AtCoder] Solve A problem of ABC101 ~ 169 with Python
Periodically run a python program on AWS Lambda
Build python environment with pyenv on EC2 (ubuntu)
Hello World with nginx + uwsgi + python on EC2
Solve A ~ D of yuki coder 247 with python
Creating an AWS EC2 EC2 Instance (Amazon Linux AMI) 2
Folium: Visualize data on a map with Python
Start a process with a scheduling policy on Linux
Run Flask on CentOS with python3.4, Gunicorn + Nginx.
Put Python3 in Docker container of Amazon Linux2
Decrypt a string encrypted on iOS with Python
Until you install Python with pythonbrew and run Flask on a WSGI server
Install PHP 7 series on Amazon Linux 2 with Amazon Linux Extras
Build a TensorFlow development environment on Amazon EC2 with command copy and paste
Visualize grib2 on a map with python (matplotlib)
Until you create a machine learning environment with Python on Windows 7 and run it
A memo connected to HiveServer2 of EMR with python
Run Kali Linux on Windows with GUI (without VirtualBox)
Recommendation of building a portable Python environment with conda
Run a machine learning pipeline with Cloud Dataflow (Python)
# 2 Build a Python environment on AWS EC2 instance (ubuntu18.04)
Create Amazon Linux with AWS EC2 and log in
Yum command to access MySQL with Python 3 on Linux
Make your cursor a photo of your choice on Linux
Run Paints Chainer on CPU with official python on win10
Make a breakpoint on the c layer with python
I made a Python3 environment on Ubuntu with direnv.
Create a batch of images and inflate with ImageDataGenerator
Execute python3 system with PHP exec () on AWS EC2