Skip to content
site logo mobile

Forum in maintenance, we will back soon 🙂

Error while using G...
 
Notifications
Clear all

Error while using Generate content Idea python code

20 Posts
5 Users
7 Likes
197 Views
(@santosh776)
Posts: 30
Trusted Member
Premium Member
Pythonista Prodigy Badge
Prompt Engineer
Topic starter
 

Please find attached screen shot of error . i am facing while running Generate content idea python code.

Screenshot 2024 01 19 135210

 

 
Posted : 01/19/2024 11:27 am
SSAdvisor
(@ssadvisor)
Posts: 927
Noble Member
Premium Member
Pythonista Prodigy Badge
Prompt Engineer
API Entrepreneur
Power Member
 

This is a result of your system policies. You'll need to research on what to change to allow you to use your system to do this.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 01/19/2024 9:17 pm
Hasan Aboul Hasan
(@admin)
Posts: 957
Member Admin
Premium Member
Pythonista Prodigy Badge
Prompt Engineer
API Entrepreneur
Power Member
 

HI friend, this is the same thread on Discord: https://discord.com/channels/1141633014342893608/1141634844909129739/1197639233385549864

is it you?

 
Posted : 01/21/2024 12:16 pm
(@naveedbaig1)
Posts: 14
Active Member
 

 i have different error while i run the code, is this tool available on your website here or not? if not please upload it there so we can use it. thanks hasan sir

 
Posted : 01/24/2024 3:49 pm
SSAdvisor
(@ssadvisor)
Posts: 927
Noble Member
Premium Member
Pythonista Prodigy Badge
Prompt Engineer
API Entrepreneur
Power Member
 

@naveedbaig1 what tool are you talking about?

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 01/24/2024 4:27 pm
(@naveedbaig1)
Posts: 14
Active Member
 

@ssadvisor AI-CONTENT IDEA GENERATOR TOOL , THE ONE ADMIN SHOWED ON HIS YOUTUBE CHANNEL

 
Posted : 01/24/2024 4:39 pm
(@naveedbaig1)
Posts: 14
Active Member
 

I AM GETTING THIS ERROR WHEN I RUN IT

Traceback (most recent call last):
 line 4, in <module>
from pydantic import BaseModel # Pydantic for data validation and settings management
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'pydantic'

 
Posted : 01/24/2024 4:41 pm
SSAdvisor
(@ssadvisor)
Posts: 927
Noble Member
Premium Member
Pythonista Prodigy Badge
Prompt Engineer
API Entrepreneur
Power Member
 

@naveedbaig1

pip install pydantic

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 01/24/2024 9:10 pm
naveed baig reacted
(@naveedbaig1)
Posts: 14
Active Member
 

one error left to solve, getting this error now.

ImportError: cannot import name 'search_google_web_automation' from 'serp' (C:\Users\naveed\AppData\Local\Programs\Python\Python313\Lib\site-packages\serp\__init__.py)

 
Posted : 02/01/2024 4:00 am
SSAdvisor
(@ssadvisor)
Posts: 927
Noble Member
Premium Member
Pythonista Prodigy Badge
Prompt Engineer
API Entrepreneur
Power Member
 

@naveedbaig1 please supply the output of 

pip freeze

so we can see what you've installed. The code supplied by @Hasan has a serp.py file which will get in the way of any global package named serp.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 02/01/2024 5:31 pm
(@naveedbaig1)
Posts: 14
Active Member
 

@ssadvisor what is the solution to that. what should i do. uninstall serp (global)? thanks

 
Posted : 02/03/2024 10:21 pm
(@naveedbaig1)
Posts: 14
Active Member
 

@ssadvisor

httpx==0.26.0
idna==3.6
itsdangerous==2.1.2
Jinja2==3.1.3
lib==4.0.0
linker==0.1.0
MarkupSafe==2.1.4
pydantic==2.6.0
pydantic_core==2.16.1
pymongo==4.6.1
requests==2.31.0
serp==0.1.5
sniffio==1.3.0
soupsieve==2.5
typing_extensions==4.9.0
urllib3==2.2.0
websockets==10.4
Werkzeug==3.0.1
winapi==0.0.0
windows==0.1.1

 
Posted : 02/03/2024 10:23 pm
SSAdvisor
(@ssadvisor)
Posts: 927
Noble Member
Premium Member
Pythonista Prodigy Badge
Prompt Engineer
API Entrepreneur
Power Member
 

@naveedbaig1 so you do have a package named serp installed. Do you know why it is there?

You have two options, one is to simply uninstall the serp package if you don't need it, the other is to use a virtual environment and install only the modules you need for a particular project.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 02/04/2024 8:40 am
naveed baig reacted
(@naveedbaig1)
Posts: 14
Active Member
 

@ssadvisor error still stays there even after uninstalling the serp

 
Posted : 02/08/2024 12:28 pm
(@husein)
Posts: 267
Member Moderator
Premium Member
Prompt Engineer
Pythonista Prodigy Badge
API Entrepreneur
Power Member
 

@naveedbaig1 Try using a virtual environment as @ssadvisor mentioned.

Anyways, please send a screenshot of your code and the error.

 
Posted : 02/08/2024 12:54 pm
(@naveedbaig1)
Posts: 14
Active Member
 

@husein

one error left to solve, getting this error now.

ImportError: cannot import name 'search_google_web_automation' from 'serp' (C:\Users\naveed\AppData\Local\Programs\Python\Python313\Lib\site-packages\serp\__init__.py)

 

also im facing trouble building some wheel

this error is than the one mentioned above

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for cffi
Failed to build cffi
ERROR: Could not build wheels for cffi, which is required to install pyproject.toml-based projects

 

 
Posted : 02/09/2024 3:08 pm
SSAdvisor
(@ssadvisor)
Posts: 927
Noble Member
Premium Member
Pythonista Prodigy Badge
Prompt Engineer
API Entrepreneur
Power Member
 

@naveedbaig1

Posted by: @naveedbaig1

ImportError: cannot import name 'search_google_web_automation' from 'serp' (C:\Users\naveed\AppData\Local\Programs\Python\Python313\Lib\site-packages\serp\__init__.py)

You need to 

pip uninstall serp

The problem is that the package serp is being imported instead of the serp.py file provided by @Hasan.

Posted by: @naveedbaig1

ERROR: Failed building wheel for cffi
Failed to build cffi
ERROR: Could not build wheels for cffi, which is required to install pyproject.toml-based projects

You might need to install some development tools and/or libraries. However you might be able to resolve this by doing

pip install -U pip

but your luck with this might not be good.

HTH

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 02/10/2024 12:25 am
naveed baig reacted
(@naveedbaig1)
Posts: 14
Active Member
 

@husein

# Importing necessary libraries and functions
import json  # Used for working with JSON data
import asyncio  # Used for asynchronous programming
from pydantic import BaseModel  # Pydantic for data validation and settings management
from typing import List  # Used for type hinting
from serp import search_google_web_automation  # Custom function to automate Google searches
from my_functions import get_article_from_url, generate_ideas  # Custom functions for processing articles

# Setting input parameters
search_query = "AI learning ideas"  # The query to search for
NUMBER_OF_RESULTS = 10  # Number of search results to process

# Template for the prompt to be used later
prompt = "extract 5-10 content ideas from the [post], and return the list in json format, [post]: {post}"

# Pydantic model for data validation
class Ideas(BaseModel):
    ideas: List[str]  # Defines a list of strings to store ideas

# Main asynchronous function
async def main():
    # Step 1: Fetch the top 100 search results
    try:
        # Fetch search results using a custom function
        search_results = search_google_web_automation(search_query,NUMBER_OF_RESULTS)
    except Exception as e:
        # Handle exceptions during search and print error message
        print(f"Error fetching search results: {e}")
        return

    # Step 2: Initialize a list to store all ideas
    all_ideas = []  # List to store the ideas generated

    # Step 3: Process each search result
    for result in search_results:
        try:
            # Extract URL from the search result
            result_url = result["url"]
            # Get article content from the URL using a custom function
            result_content = get_article_from_url(result_url)

            # If content is successfully retrieved
            if result_content:
                # Format the prompt with the retrieved content
                result_prompt = prompt.format(post=result_content)
                # Generate ideas using another custom asynchronous function
                ideas_object = await generate_ideas(result_prompt, Ideas)

                # If ideas are generated, extend the all_ideas list
                if ideas_object and ideas_object.ideas:
                    all_ideas.extend(ideas_object.ideas)
        except Exception as e:
            # Handle exceptions during processing of each result
            print(f"Error processing search result {result}: {e}")

    # Step 4: Convert the ideas to JSON and output
    # Serialize the list of ideas into a JSON formatted string
    json_output = json.dumps(all_ideas, indent=4)
    # Print the JSON string
    print(json_output)

# Check if the script is run directly and not imported
if __name__ == "__main__":
    # Run the main function using asyncio
    asyncio.run(main())
 
Posted : 02/10/2024 8:09 pm
(@naveedbaig1)
Posts: 14
Active Member
 

@ssadvisor tried after uninstalling serp, but error is still there, in the beginning there were 6 errors now im left with one error

 

 
Posted : 02/10/2024 8:11 pm
SSAdvisor
(@ssadvisor)
Posts: 927
Noble Member
Premium Member
Pythonista Prodigy Badge
Prompt Engineer
API Entrepreneur
Power Member
 

@naveedbaig1 try renaming the serp.py file from Hasan to something else like hasan_serp.py. You'll need to adjust the code to import from hasan_serp instead of serp.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 02/10/2024 8:35 pm
naveed baig reacted
Share: