Why does it run normally when executed directly, but throws an error when using PyInstaller:
curl_cffi.curl.CurlError: Failed to perform, curl: (35) BoringSSL SSL_connect: SSL_ERROR_SYSCALL in connection to localhost.weixin.qq.com:14016 . See https://curl.se/libcurl/c/libcurl-errors.html first for more details.
My code:
from curl_cffi import requests
import sys
import _ssl
from urllib.parse import quote
url = 'https://localhost.weixin.qq.com:14013/api/check-login' # one of the port numbers: 13013 or 13014 or 13015 or 14013 or 14014 or 14015
r = requests.get(url, impersonate="chrome124")
print(r.text)
- Running directly:
PS D:\script> python wx_test1.py
{"apiname":"","errcode":10000,"errmsg":"系统错误,错误码:10000"}
- PyInstaller compilation:
D:\script>c:\Python312\Scripts\pyinstaller.exe -F wx_test1.py --hidden-import=_cffi_backend --collect-all curl_cffi
462 INFO: PyInstaller: 6.11.1, contrib hooks: 2024.10
462 INFO: Python: 3.12.5
513 INFO: Platform: Windows-11-10.0.22631-SP0
513 INFO: Python environment: C:\Python312
514 INFO: wrote D:\script\wx_test1.spec
3079 INFO: Module search paths (PYTHONPATH):
['c:\\Python312\\Scripts\\pyinstaller.exe',
'D:\\script',
'C:\\Python312\\python312.zip',
'C:\\Python312\\DLLs',
'C:\\Python312\\Lib',
'C:\\Python312',
'C:\\Python312\\Lib\\site-packages',
'C:\\Python312\\Lib\\site-packages\\win32',
'C:\\Python312\\Lib\\site-packages\\win32\\lib',
'C:\\Python312\\Lib\\site-packages\\Pythonwin',
'C:\\Python312\\Lib\\site-packages\\setuptools\\_vendor',
'D:\\script']
3881 INFO: Appending 'datas' from .spec
3885 INFO: checking Analysis
3885 INFO: Building Analysis because Analysis-00.toc is non existent
3885 INFO: Running Analysis Analysis-00.toc
3885 INFO: Target bytecode optimization level: 0
3885 INFO: Initializing module dependency graph...
3885 INFO: Initializing module graph hook caches...
3899 INFO: Analyzing base_library.zip ...
6212 INFO: Processing standard module hook 'hook-encodings.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
7906 INFO: Processing standard module hook 'hook-pickle.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
8814 INFO: Processing standard module hook 'hook-heapq.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
9145 INFO: Caching module dependency graph...
9264 INFO: Looking for Python shared library...
9272 INFO: Using Python shared library: C:\Python312\python312.dll
9272 INFO: Analyzing D:\script\wx_test1.py
9317 INFO: Processing standard module hook 'hook-platform.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
9357 INFO: Processing standard module hook 'hook-certifi.py' from 'C:\\Python312\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\stdhooks'
9496 INFO: Processing standard module hook 'hook-multiprocessing.util.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
9636 INFO: Processing standard module hook 'hook-xml.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
10403 INFO: Processing pre-safe-import-module hook 'hook-typing_extensions.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
10404 INFO: SetuptoolsInfo: initializing cached setuptools info...
14516 INFO: Processing standard module hook 'hook-gevent.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
17114 INFO: Processing standard module hook 'hook-psutil.py' from 'C:\\Python312\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\stdhooks'
17273 INFO: Processing standard module hook 'hook-zope.interface.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
17333 INFO: Processing standard module hook 'hook-difflib.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
17665 INFO: Processing standard module hook 'hook-psycopg2.py' from 'C:\\Python312\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\stdhooks'
17846 INFO: Processing standard module hook 'hook-cryptography.py' from 'C:\\Python312\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\stdhooks'
19858 INFO: Processing standard module hook 'hook-bcrypt.py' from 'C:\\Python312\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\stdhooks'
20106 INFO: Processing module hooks (post-graph stage)...
20110 WARNING: Hidden import "mx.DateTime" not found!
20303 INFO: Processing standard module hook 'hook-pycparser.py' from 'C:\\Python312\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\stdhooks'
20647 INFO: Processing standard module hook 'hook-setuptools.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
20654 INFO: Processing pre-safe-import-module hook 'hook-distutils.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
20692 INFO: Processing standard module hook 'hook-sysconfig.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
20894 INFO: Processing pre-safe-import-module hook 'hook-packaging.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
20895 INFO: Processing standard module hook 'hook-packaging.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
20897 INFO: Processing pre-safe-import-module hook 'hook-jaraco.text.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
20899 INFO: Setuptools: 'jaraco.text' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.jaraco.text'!
20908 INFO: Processing standard module hook 'hook-setuptools._vendor.jaraco.text.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
20909 INFO: Processing pre-safe-import-module hook 'hook-importlib_resources.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
20911 INFO: Processing standard module hook 'hook-importlib_resources.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
20933 INFO: Processing pre-safe-import-module hook 'hook-zipp.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
20960 INFO: Processing pre-safe-import-module hook 'hook-jaraco.functools.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
20960 INFO: Setuptools: 'jaraco.functools' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.jaraco.functools'!
20967 INFO: Processing pre-safe-import-module hook 'hook-more_itertools.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
21054 INFO: Processing pre-safe-import-module hook 'hook-jaraco.context.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
21055 INFO: Setuptools: 'jaraco.context' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.jaraco.context'!
21063 INFO: Processing pre-safe-import-module hook 'hook-backports.tarfile.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
21063 INFO: Setuptools: 'backports.tarfile' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.backports.tarfile'!
21144 INFO: Processing standard module hook 'hook-backports.py' from 'C:\\Python312\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\stdhooks'
21266 INFO: Processing pre-safe-import-module hook 'hook-importlib_metadata.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
21286 INFO: Processing standard module hook 'hook-importlib_metadata.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
21378 INFO: Processing pre-safe-import-module hook 'hook-ordered_set.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
21477 INFO: Processing pre-safe-import-module hook 'hook-tomli.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
21477 INFO: Setuptools: 'tomli' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.tomli'!
21880 INFO: Processing standard module hook 'hook-pkg_resources.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
22535 INFO: Processing pre-safe-import-module hook 'hook-platformdirs.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
22542 INFO: Processing standard module hook 'hook-platformdirs.py' from 'C:\\Python312\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\stdhooks'
22603 INFO: Processing pre-safe-import-module hook 'hook-wheel.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module'
22604 INFO: Setuptools: 'wheel' appears to be a setuptools-vendored copy - creating alias to 'setuptools._vendor.wheel'!
23520 INFO: Processing pre-find-module-path hook 'hook-tkinter.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path'
23520 INFO: TclTkInfo: initializing cached Tcl/Tk info...
23834 INFO: Processing standard module hook 'hook-_tkinter.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
24775 WARNING: Hidden import "importlib_resources.trees" not found!
24821 INFO: Processing standard module hook 'hook-_tkinter.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
24830 INFO: Processing standard module hook 'hook-docutils.py' from 'C:\\Python312\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\stdhooks'
29309 INFO: Processing standard module hook 'hook-xml.dom.domreg.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
29482 INFO: Processing standard module hook 'hook-pygments.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
32660 INFO: Processing standard module hook 'hook-PIL.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
32745 INFO: Processing standard module hook 'hook-PIL.Image.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
33384 INFO: Processing standard module hook 'hook-numpy.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
36212 INFO: Processing standard module hook 'hook-charset_normalizer.py' from 'C:\\Python312\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\stdhooks'
36518 INFO: Processing standard module hook 'hook-xml.etree.cElementTree.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
36899 INFO: Processing standard module hook 'hook-PIL.ImageFilter.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
39551 INFO: Processing standard module hook 'hook-PIL.SpiderImagePlugin.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'
39600 INFO: Performing binary vs. data reclassification (1017 entries)
39750 INFO: Looking for ctypes DLLs
39813 INFO: Analyzing run-time hooks ...
39819 INFO: Including run-time hook 'pyi_rth_inspect.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks'
39820 INFO: Including run-time hook 'pyi_rth_pkgutil.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks'
39824 INFO: Including run-time hook 'pyi_rth_multiprocessing.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks'
39826 INFO: Including run-time hook 'pyi_rth_cryptography_openssl.py' from 'C:\\Python312\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\rthooks'
39827 INFO: Including run-time hook 'pyi_rth_pkgres.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks'
39832 INFO: Including run-time hook 'pyi_rth_setuptools.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks'
39834 INFO: Including run-time hook 'pyi_rth__tkinter.py' from 'C:\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks'
39869 INFO: Looking for dynamic libraries
40974 INFO: Extra DLL search directories (AddDllDirectory): ['C:\\Python312\\Lib\\site-packages\\curl_cffi.libs']
40974 INFO: Extra DLL search directories (PATH): []
41818 INFO: Warnings written to D:\script\build\wx_test1\warn-wx_test1.txt
41935 INFO: Graph cross-reference written to D:\script\build\wx_test1\xref-wx_test1.html
41975 INFO: checking PYZ
41975 INFO: Building PYZ because PYZ-00.toc is non existent
41975 INFO: Building PYZ (ZlibArchive) D:\script\build\wx_test1\PYZ-00.pyz
43023 INFO: Building PYZ (ZlibArchive) D:\script\build\wx_test1\PYZ-00.pyz completed successfully.
43104 INFO: checking PKG
43104 INFO: Building PKG because PKG-00.toc is non existent
43104 INFO: Building PKG (CArchive) wx_test1.pkg
48259 INFO: Building PKG (CArchive) wx_test1.pkg completed successfully.
48273 INFO: Bootloader C:\Python312\Lib\site-packages\PyInstaller\bootloader\Windows-64bit-intel\run.exe
48273 INFO: checking EXE
48274 INFO: Building EXE because EXE-00.toc is non existent
48274 INFO: Building EXE from EXE-00.toc
48274 INFO: Copying bootloader EXE to D:\script\dist\wx_test1.exe
48278 INFO: Copying icon to EXE
48281 INFO: Copying 0 resources to EXE
48281 INFO: Embedding manifest in EXE
48284 INFO: Appending PKG archive to EXE
48302 INFO: Fixing EXE headers
48537 INFO: Building EXE from EXE-00.toc completed successfully.
- Running the compiled executable results in an error:
D:\script>D:\script\dist\wx_test1.exe
Traceback (most recent call last):
File "curl_cffi\requests\session.py", line 1050, in request
File "curl_cffi\curl.py", line 292, in perform
File "curl_cffi\curl.py", line 137, in _check_error
curl_cffi.curl.CurlError: Failed to perform, curl: (35) BoringSSL SSL_connect: SSL_ERROR_SYSCALL in connection to localhost.weixin.qq.com:14013 . See https://curl.se/libcurl/c/libcurl-errors.html first for more details.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "wx_test1.py", line 8, in <module>
r = requests.get(url, impersonate="chrome124")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "curl_cffi\requests\__init__.py", line 133, in request
File "curl_cffi\requests\session.py", line 1055, in request
curl_cffi.requests.exceptions.SSLError: Failed to perform, curl: (35) BoringSSL SSL_connect: SSL_ERROR_SYSCALL in connection to localhost.weixin.qq.com:14013 . See https://curl.se/libcurl/c/libcurl-errors.html first for more details.
[PYI-46448:ERROR] Failed to execute script 'wx_test1' due to unhandled exception!
Versions
- OS: windows11
- curl_cffi version 0.7.3
Prerequisites: Install WeChat and log in.
The latest version of Windows WeChat opens one of the following ports when logged in: 13013 or 13014 or 13015 or 14013 or 14014 or 14015.
Why does it run normally when executed directly, but throws an error when using PyInstaller:
My code:
Versions
Prerequisites: Install WeChat and log in.
The latest version of Windows WeChat opens one of the following ports when logged in: 13013 or 13014 or 13015 or 14013 or 14014 or 14015.