assafelovic / gpt-researcher

LLM based autonomous agent that does online comprehensive research on any given topic
https://gptr.dev
Apache License 2.0
14.25k stars 1.86k forks source link

AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'? #535

Closed virologist closed 4 months ago

virologist commented 4 months ago

MacOS M1 Version 14.5 Python 3.11.6

How meet the error? pip install -r requirements.txt What the error:

Requirement already satisfied: beautifulsoup4 in /Users/*/miniconda3/envs/bio/lib/python3.12/site-packages (from -r requirements.txt (line 2)) (4.12.2)
Requirement already satisfied: colorama in /Users/*/miniconda3/envs/bio/lib/python3.12/site-packages (from -r requirements.txt (line 3)) (0.4.6)
Collecting duckduckgo_search (from -r requirements.txt (line 4))
  Using cached duckduckgo_search-6.1.0-py3-none-any.whl.metadata (18 kB)
Collecting yahoo-search-py (from -r requirements.txt (line 5))
  Using cached yahoo-search-py-0.3.tar.gz (11 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [33 lines of output]
      Traceback (most recent call last):
        File "/Users/*/miniconda3/envs/bio/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/*/miniconda3/envs/bio/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/*/miniconda3/envs/bio/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 112, in get_requires_for_build_wheel
          backend = _build_backend()
                    ^^^^^^^^^^^^^^^^
        File "/Users/*/miniconda3/envs/bio/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 77, in _build_backend
          obj = import_module(mod_path)
                ^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/*/miniconda3/envs/bio/lib/python3.12/importlib/__init__.py", line 90, in import_module
          return _bootstrap._gcd_import(name[level:], package, level)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1304, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
        File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
        File "<frozen importlib._bootstrap_external>", line 994, in exec_module
        File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
        File "/private/var/folders/vn/c8v46nts0ql7qr5yqg81xtfm0000gn/T/pip-build-env-ttr7s6ko/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 16, in <module>
          import setuptools.version
        File "/private/var/folders/vn/c8v46nts0ql7qr5yqg81xtfm0000gn/T/pip-build-env-ttr7s6ko/overlay/lib/python3.12/site-packages/setuptools/version.py", line 1, in <module>
          import pkg_resources
        File "/private/var/folders/vn/c8v46nts0ql7qr5yqg81xtfm0000gn/T/pip-build-env-ttr7s6ko/overlay/lib/python3.12/site-packages/pkg_resources/__init__.py", line 2191, in <module>
          register_finder(pkgutil.ImpImporter, find_on_path)
                          ^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
KgotsoK commented 4 months ago

Also having the same issue on WSL Ubuntu 24.04, Python 3.12.

The only way I can run this project is via docker.

AdamJablonski commented 4 months ago

Since it's yahoo search API, commenting it out from requirements.txt should unblock installation of other requirements. But you'll need to install it back manually, since TavilySearch relies on yahoo_search

KgotsoK commented 4 months ago

Found a way forward. Basically, because the docker container uses python 3.11.4 and can run this project just fine, I switched to that version by using Conda.

  1. Install Conda by following a guide of your choice, like: https://medium.com/@mustafa_kamal/a-step-by-step-guide-to-installing-conda-in-ubuntu-and-creating-an-environment-d4e49a73fc46
  2. In the guide, you create an environment. Use this command instead: conda create --name gpt-researcher python=3.11.4
  3. Activate the environment: conda activate gpt-researcher
  4. Then install the requirements using pip, and it should work this time: pip install -r requirements.txt
assafelovic commented 4 months ago

Hey everyone removed yahoo search since it's causing issues.This was nice to have as another fallback for search engines: https://github.com/assafelovic/gpt-researcher/commit/2347cf2ac0b598e52efcb7d41bf42f36f661b34a

assafelovic commented 4 months ago

Pull latest if you still can't get it running and should be resolved.

virologist commented 4 months ago

Thanks for your help. Would it be appropriate to comment out the yahoo-search-py line in requirements.txt? # yahoo-search-py