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 'formatargspec' from 'inspect' #884

Closed
kirevdokimov opened this issue Jul 21, 2023 · 10 comments
Closed

ImportError: cannot import name 'formatargspec' from 'inspect' #884

kirevdokimov opened this issue Jul 21, 2023 · 10 comments
Labels
bug Something isn't working primordial Related to the primordial version of PrivateGPT, which is now frozen in favour of the new PrivateGPT

Comments

@kirevdokimov
Copy link

kirevdokimov commented Jul 21, 2023

Describe the bug and how to reproduce it
Running pip3 install -r requirements.txt causes error at some point. The relevant part of the log is down below.

Expected behavior
Dependencies installed successfully

Environment (please complete the following information):

  • Windows 11
  • Python version: 3.11.4
  • Powershell

Additional context

Collecting httpx~=0.15.0 (from argilla->unstructured==0.8.0->-r requirements.txt (line 8))
  Using cached httpx-0.15.5-py3-none-any.whl (65 kB)
Collecting wrapt~=1.13.0 (from argilla->unstructured==0.8.0->-r requirements.txt (line 8))
  Using cached wrapt-1.13.3.tar.gz (48 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [86 lines of output]
      Traceback (most recent call last):
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\config\expand.py", line 81, in __getattr__
          return next(
                 ^^^^^
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\config\expand.py", line 82, in <genexpr>
          ast.literal_eval(value)
        File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64__qbz5n2kfra8p0\Lib\ast.py", line 110, in literal_eval
          return _convert(node_or_string)
                 ^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64__qbz5n2kfra8p0\Lib\ast.py", line 109, in _convert
          return _convert_signed_num(node)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64__qbz5n2kfra8p0\Lib\ast.py", line 83, in _convert_signed_num
          return _convert_num(node)
                 ^^^^^^^^^^^^^^^^^^
        File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64__qbz5n2kfra8p0\Lib\ast.py", line 74, in _convert_num
          _raise_malformed_node(node)
        File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64__qbz5n2kfra8p0\Lib\ast.py", line 71, in _raise_malformed_node
          raise ValueError(msg + f': {node!r}')
      ValueError: malformed node or string on line 2: <ast.Call object at 0x0000016F4FDF5330>

      The above exception was the direct cause of the following exception:

      Traceback (most recent call last):
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\config\expand.py", line 191, in read_attr
          return getattr(StaticModule(module_name, spec), attr_name)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\config\expand.py", line 87, in __getattr__
          raise AttributeError(f"{self.name} has no attribute {attr}") from e
      AttributeError: wrapt has no attribute __version__

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "C:\Users\Kirill\Documents\privateGPT\env\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\Users\Kirill\Documents\privateGPT\env\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Kirill\Documents\privateGPT\env\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 149, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\build_meta.py", line 380, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\build_meta.py", line 488, in run_setup
          self).run_setup(setup_script=setup_script)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 41, in <module>
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\__init__.py", line 107, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 159, in setup
          dist.parse_config_files()
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\dist.py", line 894, in parse_config_files
          setupcfg.parse_configuration(
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\config\setupcfg.py", line 189, in parse_configuration
          meta.parse()
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\config\setupcfg.py", line 500, in parse
          section_parser_method(section_options)
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\config\setupcfg.py", line 475, in parse_section
          self[name] = value
          ~~~~^^^^^^
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\config\setupcfg.py", line 293, in __setitem__
          parsed = self.parsers.get(option_name, lambda x: x)(value)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\config\setupcfg.py", line 606, in _parse_version
          return expand.version(self._parse_attr(value, self.package_dir, self.root_dir))
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\config\setupcfg.py", line 417, in _parse_attr
          return expand.read_attr(attr_desc, package_dir, root_dir)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\config\expand.py", line 194, in read_attr
          module = _load_spec(spec, module_name)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Kirill\AppData\Local\Temp\pip-build-env-2teo2b2k\overlay\Lib\site-packages\setuptools\config\expand.py", line 214, in _load_spec
          spec.loader.exec_module(module)  # type: ignore
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "<frozen importlib._bootstrap_external>", line 940, in exec_module
        File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
        File "C:\Users\Kirill\AppData\Local\Temp\pip-install-q2_n3rb0\wrapt_8031c0c16470415382130a89298cd5c1\src\wrapt\__init__.py", line 10, in <module>
          from .decorators import (adapter_factory, AdapterFactory, decorator,
        File "C:\Users\Kirill\AppData\Local\Temp\pip-install-q2_n3rb0\wrapt_8031c0c16470415382130a89298cd5c1\src\wrapt\decorators.py", line 34, in <module>
          from inspect import ismethod, isclass, formatargspec
      ImportError: cannot import name 'formatargspec' from 'inspect' (C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64__qbz5n2kfra8p0\Lib\inspect.py)
      [end of output]

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

× Encountered error while generating package metadata.
╰─> See above for output.
@kirevdokimov kirevdokimov added the bug Something isn't working label Jul 21, 2023
@kirevdokimov
Copy link
Author

This error is somehow related to wrapt-1.13.3.tar.gz dependency.

The manual install pip install wrapt==1.13.3 causes the exact error

@kirevdokimov
Copy link
Author

Getting through the full log, I can see a different version is installed successfully

Collecting wrapt<1.15,>=1.13 (from argilla->unstructured==0.8.0->-r requirements.txt (line 8))
  Using cached wrapt-1.14.1.tar.gz (50 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done

@kirevdokimov
Copy link
Author

Commenting the 8th line of the requirements.txt and running the command again works for me

langchain==0.0.228
gpt4all==1.0.3
chromadb==0.3.26
llama-cpp-python==0.1.68
urllib3==2.0.3
PyMuPDF==1.22.5
python-dotenv==1.0.0
# unstructured==0.8.0
extract-msg==0.41.5
tabulate==0.9.0
pandoc==2.3
pypandoc==1.11
tqdm==4.65.0

@koalamind
Copy link

Commenting the 8th line of the requirements.txt and running the command again works for me

langchain==0.0.228
gpt4all==1.0.3
chromadb==0.3.26
llama-cpp-python==0.1.68
urllib3==2.0.3
PyMuPDF==1.22.5
python-dotenv==1.0.0
# unstructured==0.8.0
extract-msg==0.41.5
tabulate==0.9.0
pandoc==2.3
pypandoc==1.11
tqdm==4.65.0

thanks for this...I had to downgrade to python 3.10 (in Window10) and it works...but will give it a try with 3.11.4 and apply the commented 8th line....anything form authors here?

@koalamind
Copy link

koalamind commented Jul 22, 2023

@Wingsky6
Copy link

I got this bug too! do anyone have solution?

@koalamind
Copy link

Try this solutions: #771 (comment)

@alph486
Copy link

alph486 commented Aug 11, 2023

I added wrapt==1.14.0 to the requirements.txt and it fixed this issue per GrahamDumpleton/wrapt#196 (comment)

@plan-9-from-outer-space

I added wrapt==1.14.0 to the requirements.txt and it fixed this issue per GrahamDumpleton/wrapt#196 (comment)

Thanks! That simple fix also worked for me.

@sharma-pratik
Copy link

I added wrapt==1.14.0 to the requirements.txt and it fixed this issue per GrahamDumpleton/wrapt#196 (comment)

This works for me. Thanks

@imartinez imartinez added the primordial Related to the primordial version of PrivateGPT, which is now frozen in favour of the new PrivateGPT label Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working primordial Related to the primordial version of PrivateGPT, which is now frozen in favour of the new PrivateGPT
Projects
None yet
Development

No branches or pull requests

7 participants