I have a very simple pipeline that fetches the AQI data and stores
them in a csv file. Here is the script:
import requests
import time
from datetime import datetime, timedelta
import csv
import sys
from tqdm import tqdm
from dotenv import load_dotenv
import os
# Load environment variables
load_dotenv()
# Get API configurations
API_KEY = os.getenv('API_KEY')
BASE_URL = os.getenv('BASE_URL')
# Coordinates for Baku
LAT = 40.3777
LON = 49.8920
# Date range for data fetching
END_DATE = datetime.now()
START_DATE = datetime(2022, 1, 13)
def fetch_daily_data(date):
"""
Fetch air quality data for a specific date
Args:
date (datetime): Date to fetch data for
Returns:
dict or None: JSON response or None if error
"""
try:
params = {
"lat": LAT,
"lon": LON,
"key": API_KEY,
"start_date": date.strftime('%Y-%m-%d'),
"end_date": (date + timedelta(days=1)).strftime('%Y-%m-%d'),
"tz": "local"
}
response = requests.get(BASE_URL, params=params)
response.raise_for_status() # Raise an exception for bad status codes
return response.json()
except requests.RequestException as e:
print(f"Error fetching data for {date.strftime('%Y-%m-%d')}: {e}")
return None
def main():
# CSV file configuration
csv_file = "baku_air_quality_data.csv"
csv_headers = ["timestamp", "aqi", "o3", "so2", "no2", "co", "pm25", "pm10"]
total_days = (END_DATE - START_DATE).days + 1
try:
with open(csv_file, "w", newline='', encoding='utf-8') as file:
writer = csv.writer(file)
writer.writerow(csv_headers)
pbar = tqdm(total=total_days, desc="Fetching data", unit="day")
current_date = START_DATE
while current_date <= END_DATE:
daily_data = fetch_daily_data(current_date)
if daily_data and 'data' in daily_data:
for hour_data in daily_data['data']:
row = [
hour_data.get('timestamp_local', ''),
hour_data.get('aqi', ''),
hour_data.get('o3', ''),
hour_data.get('so2', ''),
hour_data.get('no2', ''),
hour_data.get('co', ''),
hour_data.get('pm25', ''),
hour_data.get('pm10', '')
]
writer.writerow(row)
current_date += timedelta(days=1)
pbar.update(1)
time.sleep(1) # Respect API rate limits
pbar.close()
print(f"Data saved to {csv_file}")
except Exception as e:
print(f"An error occurred: {e}")
sys.exit(1)
if __name__ == "__main__":
main()
And this is the yaml file that describes my workflow
name: Run Script Every 3 Days
on:
push
jobs:
run-script:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set Up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install Dependencies
env:
API_KEY: ${{ secrets.API_KEY }}
run: |
pip install -r requirements.txt # If your script has dependencies
- name: Run the Script
run: |
python feature_pipeline.py # Replace with the name of your script
The error I am encountering
ERROR: Could not find a version that satisfies the requirement ipython==8.29.0
(from versions: 0.10, 0.10.1, 0.10.2, 0.11, 0.12, 0.12.1, 0.13, 0.13.1, 0.13.2,
...)
ERROR: No matching distribution found for ipython==8.29.0
Even if I change the library version, it fails in another library.
Requirements.txt
appnope==0.1.4
asttokens==2.4.1
awscli==1.36.1
boto3==1.35.60
botocore==1.35.60
certifi==2024.8.30
charset-normalizer==3.4.0
colorama==0.4.6
comm==0.2.2
contourpy==1.3.0
cycler==0.12.1
debugpy==1.8.7
decorator==5.1.1
docutils==0.16
executing==2.1.0
fonttools==4.54.1
idna==3.10
ipykernel==6.29.5
ipython==8.29.0
jedi==0.19.1
jmespath==1.0.1
joblib==1.4.2
jupyter_client==8.6.3
jupyter_core==5.7.2
kiwisolver==1.4.7
matplotlib==3.9.2
matplotlib-inline==0.1.7
nest-asyncio==1.6.0
numpy==2.1.2
packaging==24.1
pandas==2.2.3
parso==0.8.4
patsy==0.5.6
pexpect==4.9.0
pillow==11.0.0
platformdirs==4.3.6
prompt_toolkit==3.0.48
psutil==6.1.0
ptyprocess==0.7.0
pure_eval==0.2.3
pyarrow==18.0.0
pyasn1==0.6.1
Pygments==2.18.0
pyparsing==3.2.0
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
pytz==2024.2
PyYAML==6.0.2
pyzmq==26.2.0
requests==2.32.3
rsa==4.7.2
s3transfer==0.10.3
scikit-learn==1.5.2
scipy==1.14.1
seaborn==0.13.2
setuptools==75.5.0
six==1.16.0
stack-data==0.6.3
statsmodels==0.14.4
threadpoolctl==3.5.0
tornado==6.4.1
tqdm==4.66.5
traitlets==5.14.3
tzdata==2024.2
urllib3==2.2.3
wcwidth==0.2.13
wheel==0.45.0
I have tried different operating systems, upgraded pip, updated setuptools wheel and pip caching but result is the same.
2
Answers
ipython==8.29.0
requires Python 3.10 or newer, which is why installing it onpython-version: 3.9
(from yoursetup-python
action) fails.I would recommend just bumping the Python version to e.g.
python-version: "3.12"
(not necessarily the latest and greatest, 3.13, yet, because not all dependencies might be yet compiled for it).That said, it looks like you should (also) probably simplify your
requirements.txt
to e.g.as those are the direct external dependencies I see in your script.
I guess incorrect Python version. You cannot be on Python3.9 because ipython is only supported through 3.18.1.
You need to either
You can check available library versions:
Solution, edit your CI file:
BTW, if you need to regenerate requirements.txt use: