Skip to content

Latest commit

 

History

History
67 lines (42 loc) · 2.02 KB

python.md

File metadata and controls

67 lines (42 loc) · 2.02 KB

Python

Python is a popular and easy to use general purpose programming language that is heavily used in Data Analytics and Data Science as well as systems administration.

It's not as amazing for one-liners are Perl is though, which can boost shell scripts more easily.

Core Reading

Learning Python

DevOps Python tools

HariSekhon/DevOps-Python-tools

Shell scripts with Python

Shell scripts using Python and making it easier to install Python pip libraries from PyPI.

HariSekhon/DevOps-Bash-tools

Nagios Plugins in Python

HariSekhon/Nagios-Plugins

Python Library with Unit Tests

HariSekhon/pylib

VirtualEnv

Creates a virtual environment in the local given sub-directory in which to install PyPI modules to avoid clashes with system python libraries.

virtualenv "$directory_name_to_create"

I like top always the directory name venv for the virtualenv:

virtualenv venv

Then to use it before you starting pip installing:

source venv/bin/activate

This prepends to $PATH to use the bin/python and lib/python-3.12/site-packages under the local venv directory:

Now install PyPI modules as usual.

The venv/pyvenv.cfg file will contain some metadata like this:

home = /opt/homebrew/Cellar/python@3.12/3.12.3/bin
implementation = CPython
version_info = 3.12.3.final.0
virtualenv = 20.25.3
include-system-site-packages = false
base-prefix = /opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12
base-exec-prefix = /opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12
base-executable = /opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/bin/python3.12
Partial port from private Knowledge Base page 2008+