首页 > 解决方案 > torbrowser-launcher 因导入 QtCore 而失败

问题描述

使用产品torbrowser-launcher在 Fedora 33 上安装和启动Python 3.9.6

Traceback (most recent call last):
  File "/usr/bin/torbrowser-launcher", line 29, in <module>
    import torbrowser_launcher
  File "/usr/lib/python3.9/site-packages/torbrowser_launcher/__init__.py", line 34, in <module>
    from PyQt5 import QtCore, QtWidgets
ImportError: cannot import name 'QtCore' from 'PyQt5' (unknown location)

在检查了如何torbrowser-launcher/usr/bin/torbrowser-launcher第一行启动之后

#!/usr/bin/python3 -s

我能够在交互式解释器中重现这一点

/usr/bin/python3 -s
Python 3.9.6 (default, Jul 16 2021, 00:00:00) 
[GCC 11.1.1 20210531 (Red Hat 11.1.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt5 import QtCore, QtWidgets
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'QtCore' from 'PyQt5' (unknown location)
>>>

但是,离开-s标志后,这意味着

-s     Don't add user site directory to sys.path.

它工作得很好

/usr/bin/python3
Python 3.9.6 (default, Jul 16 2021, 00:00:00) 
[GCC 11.1.1 20210531 (Red Hat 11.1.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt5 import QtCore, QtWidgets
>>>

如何解决此问题并启动torbrowser-launcher

标签: pythonpython-3.xtor

解决方案


推荐阅读