编译PyQt5脚本“隐式模块sip”时出现Nuitka错误

时间:2018-09-09 21:33:47

标签: python python-3.x pyqt pyqt5 nuitka

我正在尝试使用Nuitka:nuitka --recurse-all main.py编译Python脚本,然后返回错误:

Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\__init__.py:99: Cannot find 'cryptography' in package 'requests' as absolute import (tried cryptography).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\compat.py:41: Cannot find 'urlparse' in package 'requests' as absolute import (tried urlparse).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\compat.py:42: Cannot find 'urllib2' in package 'requests' as absolute import (tried urllib2).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\compat.py:43: Cannot find 'cookielib' in package 'requests' as absolute import (tried cookielib).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\compat.py:44: Cannot find 'Cookie' in package 'requests' as absolute import (tried Cookie).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\packages\ordered_dict.py:11: Cannot find '_abcoll' in package 'urllib3.packages' as absolute import (tried _abcoll).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\packages\ssl_match_hostname\__init__.py:13: Cannot find 'backports.ssl_match_hostname' in package 'urllib3.packages.ssl_match_hostname' as absolute import (tried backports.ssl_match_hostname).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\backports:1: Cannot find '_frozen_importlib_external' in package 'backports' as absolute import (tried _frozen_importlib_external).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\contrib\socks.py:27: Cannot find 'socks' in package 'urllib3.contrib' as absolute import (tried socks).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py:28: Cannot find 'packages.six.moves' in package 'urllib3' 1 package level up (tried urllib3.packages.six.moves,packages.six.moves).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\util\queue.py:3: Cannot find 'packages.six.moves' in package 'urllib3' 2 package levels up (tried urllib3.packages.six.moves).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\request.py:4: Cannot find 'packages.six.moves.urllib.parse' in package 'urllib3' 1 package level up (tried urllib3.packages.six.moves.urllib.parse,packages.six.moves.urllib.parse).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\request.py:4: Cannot find 'packages.six.moves.urllib' in package 'urllib3' 1 package level up (tried urllib3.packages.six.moves.urllib,packages.six.moves.urllib).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connection.py:10: Cannot find 'packages.six.moves.http_client' in package 'urllib3' 1 package level up (tried urllib3.packages.six.moves.http_client,packages.six.moves.http_client).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\contrib\pyopenssl.py:46: Cannot find 'OpenSSL.SSL' in package 'urllib3.contrib' as absolute import (tried OpenSSL.SSL).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\contrib\pyopenssl.py:46: Cannot find 'OpenSSL' in package 'urllib3.contrib' as absolute import (tried OpenSSL).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\contrib\pyopenssl.py:47: Cannot find 'cryptography' in package 'urllib3.contrib' as absolute import (tried cryptography).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\contrib\pyopenssl.py:48: Cannot find 'cryptography.hazmat.backends.openssl' in package 'urllib3.contrib' as absolute import (tried cryptography.hazmat.backends.openssl).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\contrib\pyopenssl.py:48: Cannot find 'cryptography.hazmat.backends' in package 'urllib3.contrib' as absolute import (tried cryptography.hazmat.backends).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\contrib\pyopenssl.py:48: Cannot find 'cryptography.hazmat' in package 'urllib3.contrib' as absolute import (tried cryptography.hazmat).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\contrib\pyopenssl.py:49: Cannot find 'cryptography.hazmat.backends.openssl.x509' in package 'urllib3.contrib' as absolute import (tried cryptography.hazmat.backends.openssl.x509).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\contrib\pyopenssl.py:51: Cannot find 'cryptography.x509' in package 'urllib3.contrib' as absolute import (tried cryptography.x509).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\contrib\pyopenssl.py:143: Cannot find 'cryptography.x509.extensions' in package 'urllib3.contrib' as absolute import (tried cryptography.x509.extensions).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\contrib\pyopenssl.py:150: Cannot find 'OpenSSL.crypto' in package 'urllib3.contrib' as absolute import (tried OpenSSL.crypto).
Nuitka:WARNING:C:\Users\Tearzz\AppData\Local\Programs\Python\Python36\lib\site-packages\PyQt5\__init__.py:1: Cannot find 'sip' as relative or absolute import.
Error, implicit module 'sip' expected by 'PyQt5' not found.

这就是在Python脚本中导入的内容。

from PyQt5 import QtCore, QtGui, QtWidgets
import sys, os, subprocess, webbrowser, requests

2 个答案:

答案 0 :(得分:1)

sip是不同的模块。通过pip安装

pip3 install -U sip

答案 1 :(得分:0)

首先请确保您已通过执行sip安装了pip install sip模块,然后请确保使用pyqt插件,以便nuitka冷冻机将知道如何扫描pyqt扩展模块,即:

nuitka main.py --standalone --recurse-all --plugin-enable=qt-plugins

如果这不起作用,请确保在https://github.com/kayhayen/Nuitka/issues打开github问题,并正确填写问题模板,我们是一个友好的社区,我们将在此为您提供帮助,因此将提供适当的错误报告好评; D