assafelovic / gpt-researcher

GPT based autonomous agent that does online comprehensive research on any given topic
https://gptr.dev
MIT License
12.98k stars 1.61k forks source link

ImportError: cannot import name 'GPTResearcher' from 'gpt_researcher' (unknown location) #612

Closed darvat closed 1 week ago

darvat commented 1 week ago

Hi,

after a clean pip install -U gpt-researcher nest_asyncio using:

import nest_asyncio # required for notebooks
nest_asyncio.apply()

from gpt_researcher import GPTResearcher
import asyncio

async def get_report(query: str, report_type: str) -> str:
    researcher = GPTResearcher(query, report_type)
    research_result = await researcher.conduct_research()
    report = await researcher.write_report()
    return report

if __name__ == "__main__":
    query = "which team may win the NBA finals in 2024?"
    report_type = "research_report"

    report = asyncio.run(get_report(query, report_type))
    print(report)

I get:

ImportError                               Traceback (most recent call last)
[<ipython-input-1-c4c32f704e7f>](https://localhost:8080/#) in <cell line: 4>()
      2 nest_asyncio.apply()
      3 
----> 4 from gpt_researcher import GPTResearcher
      5 import asyncio
      6 

ImportError: cannot import name 'GPTResearcher' from 'gpt_researcher' (unknown location)

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
darvat commented 1 week ago

pip show gpt-researcher

Name: gpt-researcher
Version: 0.6.8
Summary: GPT Researcher is an autonomous agent designed for comprehensive online research on a variety of tasks.
Home-page: https://github.com/assafelovic/gpt-researcher
Author: Assaf Elovic
Author-email: [assaf.elovic@gmail.com](mailto:assaf.elovic@gmail.com)
License: MIT
Location: /usr/local/lib/python3.10/dist-packages
Requires: aiofiles, arxiv, beautifulsoup4, colorama, duckduckgo-search, htmldocx, json-repair, langchain, langchain-anthropic, langchain-aws, langchain-cohere, langchain-community, langchain-fireworks, langchain-google-genai, langchain-google-vertexai, langchain-groq, langchain-huggingface, langchain-mistralai, langchain-openai, langchain-together, lxml, markdown, md2pdf, mistune, newspaper3k, openai, pandas, playwright, pydantic, PyMuPDF, python-docx, python-dotenv, python-multipart, pyyaml, requests, SQLAlchemy, tavily-python, tiktoken, unstructured, websockets
Required-by:
cannuri commented 1 week ago

I have the same problem! Did you find a solution?

cannuri commented 1 week ago

I found the problem: changing from gpt_researcher import GPTResearcher to from gpt_researcher.master import GPTResearcher in multi_agents/agents/researcher.py solved it

darvat commented 1 week ago

I have the same problem! Did you find a solution?

nah, just used an earlier version like pip install gpt-researcher==0.6.4

assafelovic commented 1 week ago

can you try upgrading to latest and see if it resolves it? @cannuri @darvat

cannuri commented 1 week ago

can you try upgrading to latest and see if it resolves it? @cannuri @darvat

Yep, works now :)

darvat commented 1 week ago

was fixed