0

I am trying to install the following packages in a pipenv virtualenv buy it has been impossible in a Mac M1. I haven't tried in another PC

I have used bot possible packages

Option 1

[packages]
pyqt5-sip = "*"
pyqt5 = "*"

Option 2

[packages]
pyqt5-sip = "==12.7.0"
pyqt5 = "==5.10.1". #This package doesn't seem to exist

I will post the different errors from te different installation methods

pipenv install

Pipfile.lock (7d18ff) out of date, updating to (bb5ccf)...
Locking [packages] dependencies...
Building requirements...
✘ Locking Failed! 

ERROR:pip.subprocessor:[present-rich] Preparing metadata (pyproject.toml) exited with 1
[ResolutionFailure]:   File "/opt/homebrew/Cellar/pipenv/2022.9.21/libexec/lib/python3.10/site-packages/pipenv/resolver.py", line 782, in _main
[ResolutionFailure]:       resolve_packages(
[ResolutionFailure]:   File "/opt/homebrew/Cellar/pipenv/2022.9.21/libexec/lib/python3.10/site-packages/pipenv/resolver.py", line 730, in resolve_packages
[ResolutionFailure]:       results, resolver = resolve(
[ResolutionFailure]:   File "/opt/homebrew/Cellar/pipenv/2022.9.21/libexec/lib/python3.10/site-packages/pipenv/resolver.py", line 709, in resolve
[ResolutionFailure]:       return resolve_deps(
[ResolutionFailure]:   File "/opt/homebrew/Cellar/pipenv/2022.9.21/libexec/lib/python3.10/site-packages/pipenv/utils/resolver.py", line 1105, in resolve_deps
[ResolutionFailure]:       results, hashes, markers_lookup, resolver, skipped = actually_resolve_deps(
[ResolutionFailure]:   File "/opt/homebrew/Cellar/pipenv/2022.9.21/libexec/lib/python3.10/site-packages/pipenv/utils/resolver.py", line 894, in actually_resolve_deps
[ResolutionFailure]:       resolver.resolve()
[ResolutionFailure]:   File "/opt/homebrew/Cellar/pipenv/2022.9.21/libexec/lib/python3.10/site-packages/pipenv/utils/resolver.py", line 689, in resolve
[ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: metadata generation failed

pipenv install --skip-lock

Installing dependencies from Pipfile...
An error occurred while installing pyqt5-sip! Will try again.
An error occurred while installing pyqt5! Will try again.
Installing initially failed dependencies...
Failed to install some dependency or packages.  The following have failed installation and attempted retry: [Requirement(_name='pyqt5-sip', vcs=None, req=NamedRequirement(name='pyqt5-sip', version='', req=Requirement.parse('pyqt5-sip'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=pyqt5-sip, path=None, uri=None, extras=(), markers=None, vcs=None, specifier=None, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=pyqt5-sip)>), markers=None, _specifiers='', index=None, editable=False, hashes=frozenset(), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=pyqt5-sip, path=None, uri=None, extras=(), markers=None, vcs=None, specifier=None, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=pyqt5-sip)>, _ireq=None), Requirement(_name='pyqt5', vcs=None, req=NamedRequirement(name='pyqt5', version='', req=Requirement.parse('pyqt5'), extras=[], editable=False, _parsed_line=<Line (editable=False, name=pyqt5, path=None, uri=None, extras=(), markers=None, vcs=None, specifier=None, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=pyqt5)>), markers=None, _specifiers='', index=None, editable=False, hashes=frozenset(), extras=(), abstract_dep=None, _line_instance=<Line (editable=False, name=pyqt5, path=None, uri=None, extras=(), markers=None, vcs=None, specifier=None, pyproject=None, pyproject_requires=None, pyproject_backend=None, ireq=pyqt5)>, _ireq=None)]

pipenv install pyqt5

Installing pyqt5...
Error:  An error occurred while installing pyqt5!
Error text: Collecting pyqt5
  Using cached PyQt5-5.15.7.tar.gz (3.2 MB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status '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/Cellar/pipenv/2022.9.21/libexec/lib/python3.10/site-packages/pipenv/patched/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/Cellar/pipenv/2022.9.21/libexec/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/opt/homebrew/Cellar/pipenv/2022.9.21/libexec/lib/python3.10/site-packages/pipenv/patched/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/opt/homebrew/Cellar/pipenv/2022.9.21/libexec/lib/python3.10/site-packages/pipenv/patched/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/z8/lhf1yvnd1tb1bvq856nr_0240000gn/T/pip-build-env-t831aefc/overlay/lib/python3.9/site-packages/sipbuild/api.py", line 46, in build_wheel
          project = AbstractProject.bootstrap('wheel',
        File "/private/var/folders/z8/lhf1yvnd1tb1bvq856nr_0240000gn/T/pip-build-env-t831aefc/overlay/lib/python3.9/site-packages/sipbuild/abstract_project.py", line 87, in bootstrap
          project.setup(pyproject, tool, tool_description)
        File "/private/var/folders/z8/lhf1yvnd1tb1bvq856nr_0240000gn/T/pip-build-env-t831aefc/overlay/lib/python3.9/site-packages/sipbuild/project.py", line 585, in setup
          self.apply_user_defaults(tool)
        File "project.py", line 69, in apply_user_defaults
          super().apply_user_defaults(tool)
        File "/private/var/folders/z8/lhf1yvnd1tb1bvq856nr_0240000gn/T/pip-build-env-t831aefc/overlay/lib/python3.9/site-packages/pyqtbuild/project.py", line 70, in apply_user_defaults
          super().apply_user_defaults(tool)
        File "/private/var/folders/z8/lhf1yvnd1tb1bvq856nr_0240000gn/T/pip-build-env-t831aefc/overlay/lib/python3.9/site-packages/sipbuild/project.py", line 236, in apply_user_defaults
          self.builder.apply_user_defaults(tool)
        File "/private/var/folders/z8/lhf1yvnd1tb1bvq856nr_0240000gn/T/pip-build-env-t831aefc/overlay/lib/python3.9/site-packages/pyqtbuild/builder.py", line 69, in apply_user_defaults
          raise PyProjectOptionException('qmake',
      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.
✘ Installation Failed 
The Dan
  • 1,408
  • 6
  • 16
  • 41

1 Answers1

1

Backstory

Here are the steps that have surely been helpful in getting pipenv to work with pyqt5 on an Apple Mac M1 machine.

A big part of this was that I've overlooked using pip instead of the pipenv command to accept the terms of licenses. This was huge wasted time since pipenv would become stuck for up to an hour before showing the failure, and to make matters worst, you won't see the error due to the license terms when you run pipenv install without the --verbose flag.

Steps

  1. Make sure you have successfully installed pyqt5 from homebrew:

    brew install pyqt@5

  2. Open your ~/.zshrc in a text editor and add the following line:

    export PATH="/opt/homebrew/opt/qt5/bin:$PATH"
    

    you might need to adapt the path based on your homebrew install folder. If you're not sure, you can run brew --prefix qt5 to find the exact path

  3. Open a new terminal or type in the existing terminal:

    source ~/.zshrc
    
  4. Go to your Python project folder and type:

    pipenv shell
    pip install pyqt5 --config-settings --confirm-license= --verbose
    
  5. Grab a coffee and wait for step 4 to complete, this will take some time, but if you ran with the '--verbose' command you should see quickly (within less than a minute) the logs:

     Querying qmake about your Qt installation...
     This is the GPL version of PyQt 5.15.9 (licensed under the GNU General  Public License) for Python 3.11.3 on darwin.
     Found the license file 'pyqt-gpl.sip'.
     Checking to see if the QtCore bindings can be built...
    

    This is good news, it means at least your installation didn't get stuck because of the license as you would if you were to run pipenv ...

    And if you're lucky, after roughly 10-15 minutes, you'll see:

    Successfully installed pyqt5-5.15.9
    

In summary:

The trick was to use pip install and NOT pipenv install within the virtual environment (run pipenv shell first)

hello
  • 11
  • 1