PacktPublishing / Neural-Search-From-Prototype-to-Production-with-Jina

Neural Search - From Prototype to Production with Jina, published by Packt
MIT License
10 stars 3 forks source link

Bug: No matching distribution found for torch==1.9.0 #21

Open NicholasDunham opened 2 years ago

NicholasDunham commented 2 years ago

Getting the following error when attempting to follow the instructions in Chapter 7's cross-modal-search example:

ERROR: Could not find a version that satisfies the requirement torch==1.9.0 (from versions: 1.11.0, 1.12.0, 1.12.1)
ERROR: No matching distribution found for torch==1.9.0

I'm using MacOS Monterey on an M2 MacBook Pro.

Steps to reproduce:

  1. Create a fresh conda environment: conda create -n demo python=3
  2. Activate the new conda environment: conda activate demo
  3. Attempt to install the requirements in the cross-modal-search directory: pip install -r requirements.txt

I was able to fix this by changing the torch line in requirements.txt to torch==1.12. However, I then ran into another problem: when installing pyqt5, pip stopped with the following error:

Collecting pyqt5==5.15
  Using cached PyQt5-5.15.0.tar.gz (3.3 MB)
  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
  ╰─> [29 lines of output]
      Traceback (most recent call last):
        File "/opt/homebrew/Caskroom/miniforge/base/envs/demo1/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 156, in prepare_metadata_for_build_wheel
          hook = backend.prepare_metadata_for_build_wheel
      AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "/opt/homebrew/Caskroom/miniforge/base/envs/demo1/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/opt/homebrew/Caskroom/miniforge/base/envs/demo1/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/opt/homebrew/Caskroom/miniforge/base/envs/demo1/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 160, in prepare_metadata_for_build_wheel
          whl_basename = backend.build_wheel(metadata_directory, config_settings)
        File "/private/var/folders/gg/sm4vz_050qxccvh6yntbqgg40000gn/T/pip-build-env-cvthvuyk/overlay/lib/python3.10/site-packages/sipbuild/api.py", line 46, in build_wheel
          project = AbstractProject.bootstrap('wheel',
        File "/private/var/folders/gg/sm4vz_050qxccvh6yntbqgg40000gn/T/pip-build-env-cvthvuyk/overlay/lib/python3.10/site-packages/sipbuild/abstract_project.py", line 87, in bootstrap
          project.setup(pyproject, tool, tool_description)
        File "/private/var/folders/gg/sm4vz_050qxccvh6yntbqgg40000gn/T/pip-build-env-cvthvuyk/overlay/lib/python3.10/site-packages/sipbuild/project.py", line 584, in setup
          self.apply_user_defaults(tool)
        File "/private/var/folders/gg/sm4vz_050qxccvh6yntbqgg40000gn/T/pip-install-xklkpdn4/pyqt5_80c104c9c2b044b9864129e6bb890dce/project.py", line 62, in apply_user_defaults
          super().apply_user_defaults(tool)
        File "/private/var/folders/gg/sm4vz_050qxccvh6yntbqgg40000gn/T/pip-build-env-cvthvuyk/overlay/lib/python3.10/site-packages/pyqtbuild/project.py", line 70, in apply_user_defaults
          super().apply_user_defaults(tool)
        File "/private/var/folders/gg/sm4vz_050qxccvh6yntbqgg40000gn/T/pip-build-env-cvthvuyk/overlay/lib/python3.10/site-packages/sipbuild/project.py", line 236, in apply_user_defaults
          self.builder.apply_user_defaults(tool)
        File "/private/var/folders/gg/sm4vz_050qxccvh6yntbqgg40000gn/T/pip-build-env-cvthvuyk/overlay/lib/python3.10/site-packages/pyqtbuild/builder.py", line 67, in apply_user_defaults
          raise PyProjectOptionException('qmake',
jina[standard]==3.1.1
      sipbuild.pyproject.PyProjectOptionException
      [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.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I then installed qt5 via Homebrew (brew install qt5) and linked it so that qmake was in the path (brew link qt5 --force).

Now when I run pip install -r requirements.txt it hangs for a long time on the pyqt5 step, but instead of giving me an error it just kills the process after a while:

Collecting pyqt5==5.15
  Using cached PyQt5-5.15.0.tar.gz (3.3 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... -[1]    48546 killed     pip install -r requirements.txt

I haven't found the time yet to figure this out—it's probably caused by an incompatibility with my MacBook's Apple silicon. Regardless, if I'm having these issues, some readers will have them as well.

violenil commented 2 years ago

Hey @NicholasDunham, I have an M1 MacBook and could not reproduce this behaviour. I just ran the following few lines successfully:

conda create -n venv-book python=3.9
conda activate venv-book
pip install -r requirements.txt

This seems to have set up all requirements successfully. Can you try this again? Perhaps your python=3 refers to an older python version that finds no matching distribution for torch==1.9.0 but I am not sure.

makram93 commented 2 years ago

Maybe you can try the steps mentioned in the StackOverflow here and here which is related to pyqt5? I do not have Mac chip MacBook so can not test it, unfortunately.

NicholasDunham commented 2 years ago

@violenil It seems to be the opposite problem: using python=3 installs Python 3.10, which doesn't find a match for torch==1.9.0. Specifying python=3.9 does install Torch 1.9.

However, that still leaves the second problem. I've been trying the solutions suggested by @makram93, but so far haven't been able to make it work. I probably can if I keep trying, but if readers run into the same problems I'm having I'm guessing they'll give up pretty quickly.

maximilianwerk commented 2 years ago

@violenil It seems to be the opposite problem: using python=3 installs Python 3.10, which doesn't find a match for torch==1.9.0. Specifying python=3.9 does install Torch 1.9.

What is meant with python=3 very much depends on your system. In one year from now it will then mean python3.11. Please pin it to 3.9.