- Python 3.8 or higher
- pip (Python package manager)
macOS:
brew update
brew install python3Linux (Ubuntu/Debian):
sudo apt update
sudo apt install python3 python3-pip python3-venvWindows: Download from python.org
It's recommended to use a virtual environment to isolate project dependencies:
# Navigate to project directory
cd /path/to/pythonbox
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
# macOS/Linux:
source venv/bin/activate
# Windows:
venv\Scripts\activate# Install all required packages
pip install -r requirements.txt
# Or install specific packages
pip install boto3 requests matplotlibpython --version
# Should output: Python 3.x.x# From project root
python src/main/python/Shipping.py
# Or navigate to the script directory
cd src/main/python
python Shipping.py
# Run specific modules
python -m storage.amazon-storage
python -m basic.arrays
python -m json.csv_to_json# Pass arguments to scripts
python src/main/python/storage/query_dynamodb.pyFor AWS-related scripts (boto3), configure your credentials:
# Configure AWS credentials
aws configure
# Or manually create ~/.aws/credentials
mkdir -p ~/.aws
cat > ~/.aws/credentials << EOF
[default]
aws_access_key_id = YOUR_ACCESS_KEY_ID
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY
[aws-federated]
aws_access_key_id = YOUR_ACCESS_KEY_ID
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY
EOF
# Set default region in ~/.aws/config
cat > ~/.aws/config << EOF
[default]
region = us-west-2
output = json
EOFpythonbox/
├── requirements.txt # Python dependencies
├── src/main/python/ # Main source code
│ ├── basic/ # Basic Python examples
│ ├── storage/ # AWS S3 and DynamoDB examples
│ ├── json/ # JSON processing
│ ├── oo/ # Object-oriented examples
│ └── files/ # File handling examples
# Format code with black
black src/main/python/
# Check code style with flake8
flake8 src/main/python/# Run mypy for type checking
mypy src/main/python/# Run tests with pytest
pytest tests/deactivate$ python3
Python 3.x.x (default, ...)
>>> import requests
>>> r = requests.get('http://api.github.com')
>>> print(r)
<Response [200]>
>>> r.text
# JSON response outputIf needed, set custom Python path:
# macOS/Linux
export PYTHONPATH="${PYTHONPATH}:/path/to/your/modules"
# Or in virtual environment (preferred method)
source venv/bin/activate