Debian模组中的PyQt5依存关系 [英] PyQt5 dependency in a module on Debian

查看:307
本文介绍了Debian模组中的PyQt5依存关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有__main__的Python模块,该模块使用PyQt5.我已经在Debian Buster盒子上安装了PyQt5:

I have a Python module with a __main__ that uses PyQt5. I've installed PyQt5 on a Debian Buster box:

apt-get install python3-pyqt5

如果执行,__main__程序将按预期运行

The __main__ program runs as expected if I execute

python3 mymodule/__main__.py

从源目录.现在,我已将该模块安装到python中:

from the source directory. Now I've installed the module into python:

python3 setup.py install

那行得通. setup.py列出了对pyqt5的依赖关系:

That worked. The setup.py lists a dependency on pyqt5:

setup(
    # ...
    install_requires=['PyQt5'],
    entry_points={"gui_scripts": ["mymodule = mymodule.__main__:main"]},

安装程序创建了一个脚本/usr/local/bin/mymodule.运行该命令时,出现错误消息:

Setup created a script /usr/local/bin/mymodule. When I run that, I get an error message:

pkg_resources.DistributionNotFound:找不到'PyQt5'分发,这是mymodule必需的

pkg_resources.DistributionNotFound: The 'PyQt5' distribution was not found and is required by mymodule

我想念什么?

尝试通过pip安装pyqt5,出现以下错误:

tried installing pyqt5 via pip, got the following error:

seva@sandbox:~$ sudo pip3 install pyqt5
Collecting pyqt5
Using cached  https://files.pythonhosted.org/packages/3a/fb/eb51731f2dc7c22d8e1a63ba88fb702727b324c6352183a32f27f73b8116/PyQt5-5.14.1.tar.gz
Installing build dependencies ... done
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.7/tokenize.py", line 447, in open
    buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-install-26kj5hrc/pyqt5/setup.py'

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-26kj5hrc/pyqt5/

推荐答案

OS级程序包管理器旨在使其内部保持一致.但是,它们并非旨在与语言包管理器进行互操作. apt-get安装的python3-pyqt5可以被其他Debian软件包识别,但不能被pip/setuptools识别.

OS-level package managers are designed to be consistent within itself. But they aren't designed to interoperate with language package managers. apt-get-installed python3-pyqt5 could be recognized by other Debian packages but not by pip/setuptools.

因此,您要么将软件包转换为.deb(例如,使用 stdeb ),将依赖项设置为python3-pyqt5,然后使用apt/apt-get/dpkg进行安装.或者您使用pip安装所有内容:

So either you convert your package to .deb (using stdeb, for example), set dependency to python3-pyqt5 and install it with apt/apt-get/dpkg. Or you install everything using pip:

pip install pyqt5
pip install .  # to install your package

如果在软件包中正确声明了依赖项,则后一个命令应该足够了-pip将运行前者本身.

If your dependencies are properly declared in the package the latter command should be enough — pip will run the former itself.

PS.另外,请考虑使用virtualenv将安装pip的程序包与系统安装的程序分开. virtualenv本身可以系统安装或用户安装:

PS. Also please consider virtualenv to separate pip-installed packages from system-installed. virtualenv itself could be system-installed or user-installed:

apt install python3-virtualenv

pip install [--user] virtualenv

这篇关于Debian模组中的PyQt5依存关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆