编译PyQt5脚本时Nuitka报错"implicit module sip"错误
Nuitka error when compiling PyQt5 script "implicit module sip" error
我正在尝试使用 Nuitka 编译 Python 脚本:nuitka --recurse-all main.py
然后 returns 错误:
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
sip
是不同的模块。通过 pip 安装它
pip3 install -U sip
首先确保你已经通过 pip install sip
安装了 sip
模块,然后确保你使用了 pyqt 插件,这样 nuitka freezer 就会知道如何扫描 pyqt 扩展模块,即:
nuitka main.py --standalone --recurse-all --plugin-enable=qt-plugins
如果这不起作用,请确保在 https://github.com/kayhayen/Nuitka/issues 打开一个 github 问题并正确填写问题模板,我们会在那里帮助您,我们是一个友好的社区,所以适当的错误报告会很受欢迎;D
我正在尝试使用 Nuitka 编译 Python 脚本:nuitka --recurse-all main.py
然后 returns 错误:
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
sip
是不同的模块。通过 pip 安装它
pip3 install -U sip
首先确保你已经通过 pip install sip
安装了 sip
模块,然后确保你使用了 pyqt 插件,这样 nuitka freezer 就会知道如何扫描 pyqt 扩展模块,即:
nuitka main.py --standalone --recurse-all --plugin-enable=qt-plugins
如果这不起作用,请确保在 https://github.com/kayhayen/Nuitka/issues 打开一个 github 问题并正确填写问题模板,我们会在那里帮助您,我们是一个友好的社区,所以适当的错误报告会很受欢迎;D