Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pymobiledevice3 包中的 install_driver_if_required 函数无法被找到 #70

Open
huiliyi-XJ opened this issue Oct 28, 2024 · 3 comments

Comments

@huiliyi-XJ
Copy link

你好在运行main.py的时候出现如下报错:
(fakerun) ...@macbook-pro iOSRealRun-cli-17 % sudo python3 main.py
/Users/.../ZJU/fakerun/lib/python3.9/site-packages/urllib3/init.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: urllib3/urllib3#3020
warnings.warn(
Traceback (most recent call last):
File "/Users/.../ZJU/iOSRealRun-cli-17/main.py", line 11, in
from init import init
File "/Users/.../ZJU/iOSRealRun-cli-17/init/init.py", line 5, in
from driver import connect
File "/Users/.../ZJU/iOSRealRun-cli-17/driver/connect.py", line 6, in
from pymobiledevice3.cli.remote import install_driver_if_required
ImportError: cannot import name 'install_driver_if_required' from 'pymobiledevice3.cli.remote' (/Users/.../ZJU/fakerun/lib/python3.9/site-packages/pymobiledevice3/cli/remote.py)

@ForeverHYX
Copy link

尝试使用python3.9,高版本与包依赖存在冲突,我本机py3.13出现了同样报错

@Chenhzjs
Copy link

Chenhzjs commented Nov 4, 2024

我遇到了同样的问题,原因是 pymobiledevice3 删去了 driver 的下载,而且有些函数名(或者所在位置)改变了,你需要这样更改:
driver/connect.py
先修改 import,因为包里函数位置变了:

import logging
import multiprocessing

from pymobiledevice3.lockdown import create_using_usbmux, LockdownClient

# from pymobiledevice3.cli.remote import install_driver_if_required
# from pymobiledevice3 import usbmux
from pymobiledevice3.cli.remote import get_device_list
from pymobiledevice3.cli.remote import RemoteServiceDiscoveryService
from pymobiledevice3.remote.core_device_tunnel_service import start_quic_tunnel 
from pymobiledevice3.cli.remote import verify_tunnel_imports

from pymobiledevice3.services.amfi import AmfiService

from pymobiledevice3.exceptions import NoDeviceConnectedError

然后修改下面的函数:

def get_serverrsd():
    # install_driver_if_required()
    if not verify_tunnel_imports():
        exit(1)
    return get_device_list()


async def tunnel(rsd: RemoteServiceDiscoveryService, queue: multiprocessing.Queue):
    async with start_quic_tunnel(rsd, None) as tunnel_result:
        queue.put((tunnel_result.address, tunnel_result.port))
        await tunnel_result.client.wait_closed()

driver/tunnel.py
修改以下的函数:

def tunnel_proc(queue: multiprocessing.Queue):
    server_rsd_list = connect.get_serverrsd()
    server_rsd = server_rsd_list[0]
    asyncio.run(connect.tunnel(server_rsd, queue))

driver/location.py
修改下面的函数,这边附上源代码的图(以后就照这样可以自己去微调啦 XD):
image

def set_location(dvt, lat: float, lng: float):
    LocationSimulation(dvt).simulate_location(lat, lng)

def clear_location(dvt):
    LocationSimulation(dvt).stop()

现在我的 iosrealrun 可以工作了(给我好好地去线下打卡x)。
最后说一下我用的是 Mac 连接 iphone。windows 是否能工作不清楚,如果试了可以的话可以在下面接一下。另外因为 pymobiledevice3 的包不再提供驱动的下载,所以需要自己下载驱动。包的提供者的说明如下:
doronz88/pymobiledevice3#1243 (comment)

希望对你有所帮助:D

@Chenhzjs
Copy link

Chenhzjs commented Nov 4, 2024

另外我的 python 版本是 3.9.20,pymobiledevice3 版本调成 2.20.0 改的,其他版本的可以自己试试,方法大差不差的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants