wkeeling / selenium-wire

Extends Selenium's Python bindings to give you the ability to inspect requests made by the browser.
MIT License
1.86k stars 241 forks source link

Python API call failed #679

Open weitaifu opened 1 year ago

weitaifu commented 1 year ago

from seleniumwire import webdriver会出现以下问题,pip install cffi后依然如故: ModuleNotFoundError: No module named '_cffi_backend' thread '' panicked at 'Python API call failed', C:\Users\runneradmin.cargo\registry\src\index.crates.io-6f17d22bba15001f\pyo3-0.15.2\src\err\mod.rs:582:5 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace Traceback (most recent call last): File "E:\文档\分区(已识别)(2)\多线程爬虫 - 副本\国家中小学智慧教育平台课程教学13.py", line 4, in from seleniumwire import webdriver File "F:\python\Lib\site-packages\seleniumwire\webdriver.py", line 28, in from seleniumwire import backend, utils File "F:\python\Lib\site-packages\seleniumwire\backend.py", line 4, in from seleniumwire.server import MitmProxy File "F:\python\Lib\site-packages\seleniumwire\server.py", line 5, in from seleniumwire.handler import InterceptRequestHandler File "F:\python\Lib\site-packages\seleniumwire\handler.py", line 5, in from seleniumwire import har File "F:\python\Lib\site-packages\seleniumwire\har.py", line 11, in from seleniumwire.thirdparty.mitmproxy import connections File "F:\python\Lib\site-packages\seleniumwire\thirdparty\mitmproxy\connections.py", line 9, in from seleniumwire.thirdparty.mitmproxy import certs, exceptions, stateobject File "F:\python\Lib\site-packages\seleniumwire\thirdparty\mitmproxy\certs.py", line 10, in import OpenSSL File "F:\python\Lib\site-packages\OpenSSL__init__.py", line 8, in from OpenSSL import SSL, crypto File "F:\python\Lib\site-packages\OpenSSL\SSL.py", line 9, in from OpenSSL._util import ( File "F:\python\Lib\site-packages\OpenSSL_util.py", line 6, in from cryptography.hazmat.bindings.openssl.binding import Binding File "F:\python\Lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 15, in from cryptography.hazmat.bindings._rust import _openssl, openssl pyo3_runtime.PanicException: Python API call failed

weitaifu commented 1 year ago

原来是python的版本过高造成的。在python3.11里就会有以上的pythonAPI call failed.而在最新的python3.10.11就完全正常运行。但是,我目前没有能力确定是python3.11里的什么原因造成的这一个问题。估计与故障提示的开头的ModuleNotFoundError: No module named 'cffi_backend'有关。因为已经安装了cffi模块,没有找到cffi_backend模块。