chrismattmann / tika-python

Tika-Python is a Python binding to the Apache Tikaβ„’ REST services allowing Tika to be called natively in the Python community.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Help installing package on macOS M2 Ventura

shamoon opened this issue Β· comments

Hi there, I have scoured the web for weeks trying to solve this, apologies if its something simple Im missing or Im barking up the wrong tree but I simply cannot get the package installed on a new Apple Silicon M2 Mac (mention the arch because I can't help but wonder if its related, was happily running on previous Intel Mac for years). Tried everything like this: https://bobbyhadz.com/blog/python-error-metadata-generation-failed-encountered-error and more I could find.

Thanks for any thoughts πŸ™

Initially install fails with

pip install tika -v
Using pip 23.0.1 from /Users/username/Documents/.../.venv/lib/python3.10/site-packages/pip (python 3.10)
Collecting tika
  Using cached tika-2.6.0.tar.gz (27 kB)
  Running command python setup.py egg_info
  Downloading https://pypi.python.org/packages/source/d/distribute/distribute-0.6.14.tar.gz
  Extracting in /var/folders/1_/rlrvyw7x5b53z9ndk9_mlcvh0000gn/T/tmp_5h8g8zo
  Traceback (most recent call last):
    File "/Users/username/Documents/.../.venv/lib/python3.10/site-packages/ez_setup.py", line 143, in use_setuptools
      raise ImportError
  ImportError

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "<string>", line 2, in <module>
    File "<pip-setuptools-caller>", line 34, in <module>
    File "/private/var/folders/1_/rlrvyw7x5b53z9ndk9_mlcvh0000gn/T/pip-install-qmpzq5td/tika_ca08f4c1467a40edbcf29da0123d8c5a/setup.py", line 29, in <module>
      use_setuptools()
    File "/Users/username/Documents/.../.venv/lib/python3.10/site-packages/ez_setup.py", line 145, in use_setuptools
      return _do_download(version, download_base, to_dir, download_delay)
    File "/Users/username/Documents/.../.venv/lib/python3.10/site-packages/ez_setup.py", line 125, in _do_download
      _build_egg(egg, tarball, to_dir)
    File "/Users/username/Documents/.../.venv/lib/python3.10/site-packages/ez_setup.py", line 99, in _build_egg
      _extractall(tar)
    File "/Users/username/Documents/.../.venv/lib/python3.10/site-packages/ez_setup.py", line 468, in _extractall
      self.chown(tarinfo, dirpath)
  TypeError: TarFile.chown() missing 1 required positional argument: 'numeric_owner'
  error: subprocess-exited-with-error
  
  Γ— python setup.py egg_info 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.
  full command: /Users/username/Documents/.../.venv/bin/python3 -c '
  exec(compile('"'"''"'"''"'"'
  # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
  #
  # - It imports setuptools before invoking setup.py, to enable projects that directly
  #   import from `distutils.core` to work with newer packaging standards.
  # - It provides a clear error message when setuptools is not installed.
  # - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
  #   setuptools doesn'"'"'t think the script is `-c`. This avoids the following warning:
  #     manifest_maker: standard file '"'"'-c'"'"' not found".
  # - It generates a shim setup.py, for handling setup.cfg-only projects.
  import os, sys, tokenize
  
  try:
      import setuptools
  except ImportError as error:
      print(
          "ERROR: Can not execute `setup.py` since setuptools is not available in "
          "the build environment.",
          file=sys.stderr,
      )
      sys.exit(1)
  
  __file__ = %r
  sys.argv[0] = __file__
  
  if os.path.exists(__file__):
      filename = __file__
      with tokenize.open(__file__) as f:
          setup_py_code = f.read()
  else:
      filename = "<auto-generated setuptools caller>"
      setup_py_code = "from setuptools import setup; setup()"
  
  exec(compile(setup_py_code, filename, "exec"))
  '"'"''"'"''"'"' % ('"'"'/private/var/folders/1_/rlrvyw7x5b53z9ndk9_mlcvh0000gn/T/pip-install-qmpzq5td/tika_ca08f4c1467a40edbcf29da0123d8c5a/setup.py'"'"',), "<pip-setuptools-caller>", "exec"))' egg_info --egg-base /private/var/folders/1_/rlrvyw7x5b53z9ndk9_mlcvh0000gn/T/pip-pip-egg-info-ftrtrihq
  cwd: /private/var/folders/1_/rlrvyw7x5b53z9ndk9_mlcvh0000gn/T/pip-install-qmpzq5td/tika_ca08f4c1467a40edbcf29da0123d8c5a/
  Preparing metadata (setup.py) ... error
error: metadata-generation-failed

Γ— Encountered error while generating package metadata.
╰─> See above for output.

I was eventually able to get past this step (using a hack, I think) but now get stuck on

(.venv) pip install tika
Collecting tika
  Using cached tika-2.6.0.tar.gz (27 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  Γ— python setup.py egg_info did not run successfully.
  β”‚ exit code: 1
  ╰─> [193 lines of output]
      Downloading https://pypi.python.org/packages/source/d/distribute/distribute-0.6.14.tar.gz
      Extracting in /var/folders/1_/rlrvyw7x5b53z9ndk9_mlcvh0000gn/T/tmpyz77xgfe
      Now working in /var/folders/1_/rlrvyw7x5b53z9ndk9_mlcvh0000gn/T/tmpyz77xgfe/distribute-0.6.14
      Building a Distribute egg in /private/var/folders/1_/rlrvyw7x5b53z9ndk9_mlcvh0000gn/T/pip-install-m5in7uif/tika_6a6c70341a87459187db6b17601fee4b
      /private/var/folders/1_/rlrvyw7x5b53z9ndk9_mlcvh0000gn/T/tmpyz77xgfe/distribute-0.6.14/setup.py:9: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
        from distutils.filelist import FileList
      creating build
      creating build/src
      creating build/src/docs
      creating build/src/docs/_templates
      creating build/src/docs/_theme
      creating build/src/docs/_theme/nature
      creating build/src/docs/_theme/nature/static
      creating build/src/docs/build
      creating build/src/docs/build/html
      creating build/src/docs/build/html/_sources
      creating build/src/docs/build/html/_static
      creating build/src/setuptools
      creating build/src/setuptools/command
      creating build/src/setuptools/tests
      creating build/src/setuptools/tests/indexes
      creating build/src/setuptools/tests/indexes/test_links_priority
      creating build/src/setuptools/tests/indexes/test_links_priority/simple
      creating build/src/setuptools/tests/indexes/test_links_priority/simple/foobar
      creating build/src/tests
      creating build/src/tests/shlib_test
      copying setuptools/package_index.py -> build/src/setuptools
      copying setuptools/archive_util.py -> build/src/setuptools
      copying setuptools/depends.py -> build/src/setuptools
      copying setuptools/__init__.py -> build/src/setuptools
      copying setuptools/sandbox.py -> build/src/setuptools
      copying setuptools/extension.py -> build/src/setuptools
      copying setuptools/dist.py -> build/src/setuptools
      copying setuptools/tests/test_resources.py -> build/src/setuptools/tests
      copying setuptools/tests/server.py -> build/src/setuptools/tests
      copying setuptools/tests/test_upload_docs.py -> build/src/setuptools/tests
      copying setuptools/tests/__init__.py -> build/src/setuptools/tests
      copying setuptools/tests/test_build_ext.py -> build/src/setuptools/tests
      copying setuptools/tests/test_sandbox.py -> build/src/setuptools/tests
      copying setuptools/tests/doctest.py -> build/src/setuptools/tests
      copying setuptools/tests/test_packageindex.py -> build/src/setuptools/tests
      copying setuptools/tests/test_develop.py -> build/src/setuptools/tests
      copying setuptools/tests/test_easy_install.py -> build/src/setuptools/tests
      copying setuptools/command/bdist_egg.py -> build/src/setuptools/command
      copying setuptools/command/alias.py -> build/src/setuptools/command
      copying setuptools/command/build_ext.py -> build/src/setuptools/command
      copying setuptools/command/easy_install.py -> build/src/setuptools/command
      copying setuptools/command/install_scripts.py -> build/src/setuptools/command
      copying setuptools/command/upload.py -> build/src/setuptools/command
      copying setuptools/command/register.py -> build/src/setuptools/command
      copying setuptools/command/bdist_wininst.py -> build/src/setuptools/command
      copying setuptools/command/install_lib.py -> build/src/setuptools/command
      copying setuptools/command/upload_docs.py -> build/src/setuptools/command
      copying setuptools/command/build_py.py -> build/src/setuptools/command
      copying setuptools/command/__init__.py -> build/src/setuptools/command
      copying setuptools/command/sdist.py -> build/src/setuptools/command
      copying setuptools/command/test.py -> build/src/setuptools/command
      copying setuptools/command/saveopts.py -> build/src/setuptools/command
      copying setuptools/command/bdist_rpm.py -> build/src/setuptools/command
      copying setuptools/command/egg_info.py -> build/src/setuptools/command
      copying setuptools/command/install.py -> build/src/setuptools/command
      copying setuptools/command/develop.py -> build/src/setuptools/command
      copying setuptools/command/rotate.py -> build/src/setuptools/command
      copying setuptools/command/install_egg_info.py -> build/src/setuptools/command
      copying setuptools/command/setopt.py -> build/src/setuptools/command
      copying setuptools/tests/win_script_wrapper.txt -> build/src/setuptools/tests
      copying setuptools/cli.exe -> build/src/setuptools
      copying setuptools/gui.exe -> build/src/setuptools
      copying tests/manual_test.py -> build/src/tests
      copying tests/test_distribute_setup.py -> build/src/tests
      copying tests/install_test.py -> build/src/tests
      copying tests/shlib_test/test_hello.py -> build/src/tests/shlib_test
      copying tests/shlib_test/setup.py -> build/src/tests/shlib_test
      copying tests/shlib_test/hello.c -> build/src/tests/shlib_test
      copying tests/shlib_test/hellolib.c -> build/src/tests/shlib_test
      copying tests/shlib_test/hello.pyx -> build/src/tests/shlib_test
      copying tests/api_tests.txt -> build/src/tests
      RefactoringTool: Skipping optional fixer: buffer
      RefactoringTool: Skipping optional fixer: idioms
      RefactoringTool: Skipping optional fixer: set_literal
      RefactoringTool: Skipping optional fixer: ws_comma
      RefactoringTool: Refactored build/src/tests/api_tests.txt
      RefactoringTool: Files that were modified:
      RefactoringTool: build/src/tests/api_tests.txt
      --- build/src/tests/api_tests.txt   (original)
      +++ build/src/tests/api_tests.txt   (refactored)
      @@ -39,7 +39,7 @@
           >>> dist.py_version == sys.version[:3]
           True
      
      -    >>> print dist.platform
      +    >>> print(dist.platform)
           None
      
       Including various computed attributes::
      @@ -199,7 +199,7 @@
       You can ask a WorkingSet to ``find()`` a distribution matching a requirement::
      
           >>> from pkg_resources import Requirement
      -    >>> print ws.find(Requirement.parse("Foo==1.0"))    # no match, return None
      +    >>> print(ws.find(Requirement.parse("Foo==1.0")))    # no match, return None
           None
      
           >>> ws.find(Requirement.parse("Bar==0.9"))  # match, return distribution
      @@ -211,7 +211,7 @@
           >>> try:
           ...     ws.find(Requirement.parse("Bar==1.0"))
           ... except VersionConflict:
      -    ...     print 'ok'
      +    ...     print('ok')
           ok
      
       You can subscribe a callback function to receive notifications whenever a new
      @@ -219,7 +219,7 @@
       once for each existing distribution in the working set, and then is called
       again for new distributions added thereafter::
      
      -    >>> def added(dist): print "Added", dist
      +    >>> def added(dist): print("Added", dist)
           >>> ws.subscribe(added)
           Added Bar 0.9
           >>> foo12 = Distribution(project_name="Foo", version="1.2", location="f12")
      copying setuptools/tests/indexes/test_links_priority/external.html -> build/src/setuptools/tests/indexes/test_links_priority
      copying setuptools/tests/indexes/test_links_priority/simple/foobar/index.html -> build/src/setuptools/tests/indexes/test_links_priority/simple/foobar
      copying docs/conf.py -> build/src/docs
      copying docs/setuptools.txt -> build/src/docs
      copying docs/easy_install.txt -> build/src/docs
      copying docs/roadmap.txt -> build/src/docs
      copying docs/index.txt -> build/src/docs
      copying docs/using.txt -> build/src/docs
      copying docs/pkg_resources.txt -> build/src/docs
      copying docs/python3.txt -> build/src/docs
      copying docs/build/html/_sources/setuptools.txt -> build/src/docs/build/html/_sources
      copying docs/build/html/_sources/easy_install.txt -> build/src/docs/build/html/_sources
      copying docs/build/html/_sources/roadmap.txt -> build/src/docs/build/html/_sources
      copying docs/build/html/_sources/index.txt -> build/src/docs/build/html/_sources
      copying docs/build/html/_sources/using.txt -> build/src/docs/build/html/_sources
      copying docs/build/html/_sources/pkg_resources.txt -> build/src/docs/build/html/_sources
      copying docs/build/html/_sources/python3.txt -> build/src/docs/build/html/_sources
      copying docs/_theme/nature/theme.conf -> build/src/docs/_theme/nature
      copying docs/build/html/_static/basic.css -> build/src/docs/build/html/_static
      copying docs/build/html/_static/pygments.css -> build/src/docs/build/html/_static
      copying docs/build/html/_static/nature.css -> build/src/docs/build/html/_static
      copying docs/_theme/nature/static/pygments.css -> build/src/docs/_theme/nature/static
      copying docs/_theme/nature/static/nature.css_t -> build/src/docs/_theme/nature/static
      copying docs/Makefile -> build/src/docs
      copying docs/_templates/indexsidebar.html -> build/src/docs/_templates
      copying easy_install.py -> build/src
      copying setup.py -> build/src
      copying site.py -> build/src
      copying distribute_setup.py -> build/src
      copying pkg_resources.py -> build/src
      copying DEVGUIDE.txt -> build/src
      copying CHANGES.txt -> build/src
      copying README.txt -> build/src
      copying CONTRIBUTORS.txt -> build/src
      copying MANIFEST.in -> build/src
      copying launcher.c -> build/src
      Skipping optional fixer: buffer
      Skipping optional fixer: idioms
      Skipping optional fixer: set_literal
      Skipping optional fixer: ws_comma
      Traceback (most recent call last):
        File "/private/var/folders/1_/rlrvyw7x5b53z9ndk9_mlcvh0000gn/T/tmpyz77xgfe/distribute-0.6.14/setup.py", line 37, in <module>
          exec(open(init_path).read(), d)
        File "<string>", line 8, in <module>
        File "/private/var/folders/1_/rlrvyw7x5b53z9ndk9_mlcvh0000gn/T/tmpyz77xgfe/distribute-0.6.14/build/src/setuptools/__init__.py", line 2, in <module>
          from setuptools.extension import Extension, Library
        File "/private/var/folders/1_/rlrvyw7x5b53z9ndk9_mlcvh0000gn/T/tmpyz77xgfe/distribute-0.6.14/build/src/setuptools/extension.py", line 2, in <module>
          from setuptools.dist import _get_unpatched
        File "/private/var/folders/1_/rlrvyw7x5b53z9ndk9_mlcvh0000gn/T/tmpyz77xgfe/distribute-0.6.14/build/src/setuptools/dist.py", line 642, in <module>
          for module in distutils.dist, distutils.core, distutils.cmd:
      AttributeError: module 'distutils' has no attribute 'dist'
      /private/var/folders/1_/rlrvyw7x5b53z9ndk9_mlcvh0000gn/T/pip-install-m5in7uif/tika_6a6c70341a87459187db6b17601fee4b/distribute-0.6.14-py3.10.egg
      Traceback (most recent call last):
        File "/Users/username/Documents/.../.venv/lib/python3.10/site-packages/ez_setup.py", line 143, in use_setuptools
          raise ImportError
      ImportError
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/1_/rlrvyw7x5b53z9ndk9_mlcvh0000gn/T/pip-install-m5in7uif/tika_6a6c70341a87459187db6b17601fee4b/setup.py", line 29, in <module>
          use_setuptools()
        File "/Users/username/Documents/.../.venv/lib/python3.10/site-packages/ez_setup.py", line 145, in use_setuptools
          return _do_download(version, download_base, to_dir, download_delay)
        File "/Users/username/Documents/.../.venv/lib/python3.10/site-packages/ez_setup.py", line 125, in _do_download
          _build_egg(egg, tarball, to_dir)
        File "/Users/username/Documents/.../.venv/lib/python3.10/site-packages/ez_setup.py", line 116, in _build_egg
          raise IOError('Could not build the egg.')
      OSError: Could not build the egg.
      [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.

hmmm, what Python are you using? Mac doesn't really ship its own (working) Python I've noticed on the newer Macs. Are you able to try pyenv? Try installing it here see if that helps @shamoon

Cheers, got me to mess around with things a bit and using 3.10.9 seems to make everything happy over here. Thanks again

Cheers, got me to mess around with things a bit and using 3.10.9 seems to make everything happy over here. Thanks again

Great to hear @shamoon !