Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'config' from 'settings' #2

Open
huseyincenik opened this issue Dec 20, 2024 · 4 comments
Open

ImportError: cannot import name 'config' from 'settings' #2

huseyincenik opened this issue Dec 20, 2024 · 4 comments

Comments

@huseyincenik
Copy link

Hello, I encountered the following error while trying to run the project:

Traceback (most recent call last):
File "C:\Users***ChicagoYIMBYblueskybot\src\main.py", line 3, in
from bot.bot_logic import BotLogic
File "C:\Users***ChicagoYIMBYblueskybot\src\bot\bot_logic.py", line 6, in
from bot.post_handler import PostHandler
File "C:\Users***ChicagoYIMBYblueskybot\src\bot\post_handler.py", line 3, in
from utils.rss_parser import fetch_image_url
File "C:\Users***ChicagoYIMBYblueskybot\src\utils\rss_parser.py", line 10, in
from settings import config
ImportError: cannot import name 'config' from 'settings' (C:\Users***ChicagoYIMBYblueskybot\src\settings.py)

@PileOfGarbage
Copy link

PileOfGarbage commented Dec 29, 2024

I resolved this issue by modifying settings.py as below (Quick-and-dirty fix, not optimal):

import os
import logging
import yaml
from dotenv import load_dotenv
from datetime import datetime

logger = logging.getLogger(__name__)

load_dotenv()

BLUESKY_USERNAME = os.getenv("BLUESKY_USERNAME")
BLUESKY_PASSWORD = os.getenv("BLUESKY_PASSWORD")
RSS_FEED_URL = os.getenv("RSS_FEED_URL")

# Minimum date for RSS entries to be posted (default to November 13, 2024)
MIN_POST_DATE = os.getenv("MIN_POST_DATE", "2024-11-13")
MIN_POST_DATE = datetime.strptime(MIN_POST_DATE, "%Y-%m-%d")

def load_config():
    """Load configuration from YAML file."""
    try:
        config_path = os.path.join(os.path.dirname(__file__), '../config.yaml')
        with open(config_path, 'r') as f:
            return yaml.safe_load(f)
    except Exception as e:
        logger.critical(f"Failed to load config file: {e}")
        raise

config = load_config()

@huseyincenik
Copy link
Author

Thanks for this. It says that ffeed cannot parse the file. Can you explain what kind of feed link should I send?
image

@PileOfGarbage
Copy link

The RSS_FEED_URL setting in your .env must be set to a well-formed URI pointing to a valid RSS feed file. This file should be in XML and conform to a spec supported by feedparser (Ideally RSS 2.0).

For example, here is the URI for the Slashdot front-page RSS feed: https://rss.slashdot.org/Slashdot/slashdotMain.

@huseyincenik
Copy link
Author

huseyincenik commented Jan 13, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants