#创建x86的python3.10的环境(很重要!使用arm版的python3.10安装会报错,见后面)
CONDA_SUBDIR=osx-64 conda create -n py310 python=3.10
#激活环境:
sjwmacn:~ sjw$ conda activate py310
(py310) sjwmacn:~ sjw$ python
Python 3.10.2 | packaged by conda-forge | (main, Feb 1 2022, 19:32:15) [Clang 11.1.0 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
#安装:
(py310) sjwmacn:~ sjw$ pip install PyQt5 -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting PyQt5
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/80/1c/46d8f76e1719a8a00921ab579ed1b908c830d356a7658ec7ceda5d421912/PyQt5-5.15.6-cp36-abi3-macosx_10_13_x86_64.whl (7.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.0/7.0 MB 2.7 MB/s eta 0:00:00
Collecting PyQt5-Qt5>=5.15.2
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/62/09/99a222b0360616250fb2e6003a54e43a2a06b0774f0f8d5daafb86a2c375/PyQt5_Qt5-5.15.2-py3-none-macosx_10_13_intel.whl (40.5 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.5/40.5 MB 1.7 MB/s eta 0:00:00
Collecting PyQt5-sip<13,>=12.8
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/23/9c/e453cd6fdc616b6930c453286cdce6b77a2ca7b6e5bb8f991c033a0155dd/PyQt5_sip-12.9.1-cp310-cp310-macosx_10_9_universal2.whl (140 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 140.3/140.3 KB 121.0 kB/s eta 0:00:00
Installing collected packages: PyQt5-Qt5, PyQt5-sip, PyQt5
Successfully installed PyQt5-5.15.6 PyQt5-Qt5-5.15.2 PyQt5-sip-12.9.1
#使用
(py310) sjwmacn:~ sjw$ python
Python 3.10.2 | packaged by conda-forge | (main, Feb 1 2022, 19:32:15) [Clang 11.1.0 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt5
直接使用arm版的python3.10安装会报错:(python3.9也试过会报错)
(py310) sjwmacn:~ sjw$ pip install PyQt5 -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting PyQt5
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3b/27/fd81188a35f37be9b3b4c2db1654d9439d1418823916fe702ac3658c9c41/PyQt5-5.15.6.tar.gz (3.2 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 2.5 MB/s eta 0:00:00
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 "/Users/sjw/mambaforge/envs/py310/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 "/Users/sjw/mambaforge/envs/py310/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
main()
File "/Users/sjw/mambaforge/envs/py310/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 "/Users/sjw/mambaforge/envs/py310/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/r8/lyyztn5j3jq3bbx3805qsxz40000gn/T/pip-build-env-2duisgzo/overlay/lib/python3.10/site-packages/sipbuild/api.py", line 51, in build_wheel
project = AbstractProject.bootstrap('pep517')
File "/private/var/folders/r8/lyyztn5j3jq3bbx3805qsxz40000gn/T/pip-build-env-2duisgzo/overlay/lib/python3.10/site-packages/sipbuild/abstract_project.py", line 83, in bootstrap
project.setup(pyproject, tool, tool_description)
File "/private/var/folders/r8/lyyztn5j3jq3bbx3805qsxz40000gn/T/pip-build-env-2duisgzo/overlay/lib/python3.10/site-packages/sipbuild/project.py", line 594, in setup
self.apply_user_defaults(tool)
File "/private/var/folders/r8/lyyztn5j3jq3bbx3805qsxz40000gn/T/pip-install-uxx7cl0x/pyqt5_4398b4adc6204c6687d27c893afc64ab/project.py", line 63, in apply_user_defaults
super().apply_user_defaults(tool)
File "/private/var/folders/r8/lyyztn5j3jq3bbx3805qsxz40000gn/T/pip-build-env-2duisgzo/overlay/lib/python3.10/site-packages/pyqtbuild/project.py", line 70, in apply_user_defaults
super().apply_user_defaults(tool)
File "/private/var/folders/r8/lyyztn5j3jq3bbx3805qsxz40000gn/T/pip-build-env-2duisgzo/overlay/lib/python3.10/site-packages/sipbuild/project.py", line 241, in apply_user_defaults
self.builder.apply_user_defaults(tool)
File "/private/var/folders/r8/lyyztn5j3jq3bbx3805qsxz40000gn/T/pip-build-env-2duisgzo/overlay/lib/python3.10/site-packages/pyqtbuild/builder.py", line 67, 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.
有人提问了,但暂时没人解答:
python - Installing PyQT in conda environment - Stack Overflow