Python on the command line

Python on the command line

Screenshot 2022-08-07 at 16.53.37.png

To check the version of python installed on your system:

Screenshot 2022-08-07 at 16.56.01.png

Screenshot 2022-08-07 at 16.59.01.png

Screenshot 2022-08-07 at 17.00.15.png

Now that we're in the interactive mode:

print('Hello world')
#returns Hello world

Screenshot 2022-08-07 at 17.05.51.png

Note that the interactive session is easy to use but it is not good for code reproducibility.

Screenshot 2022-08-07 at 17.07.50.png

Screenshot 2022-08-07 at 17.09.13.png

Screenshot 2022-08-07 at 17.10.27.png

Python package installation with pip

Screenshot 2022-08-07 at 17.16.18.png

Screenshot 2022-08-07 at 17.17.13.png

Screenshot 2022-08-07 at 17.20.29.png

Screenshot 2022-08-07 at 17.21.38.png

Screenshot 2022-08-07 at 17.22.57.png

Screenshot 2022-08-07 at 17.26.03.png

Screenshot 2022-08-07 at 17.27.33.png

#Data job automation with cron

Screenshot 2022-08-07 at 17.37.28.png

Screenshot 2022-08-07 at 17.38.50.png

Screenshot 2022-08-07 at 17.40.08.png

Screenshot 2022-08-07 at 17.41.37.png

Screenshot 2022-08-07 at 17.43.16.png

Screenshot 2022-08-07 at 17.44.45.png

Recap

# Preview both Python script and requirements text file
cat create_model.py
cat requirements.txt

# Pip install Python dependencies in requirements file
pip install -r requirements.txt

# Run Python script on command line
python create_model.py

# Add CRON job that runs create_model.py every minute
echo "* * * * * python create_model.py" | crontab

# Verify that the CRON job has been scheduled via CRONTAB
crontab -l