鱼C论坛

 找回密码
 立即注册
查看: 86|回复: 2

[已解决]python打包exe为什么路径一直报错?怎么改mediapipe的

[复制链接]
发表于 6 天前 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
报错内容
Traceback (most recent call last):
  File "2.py", line 22, in <module>
  File "cvzone\HandTrackingModule.py", line 36, in __init__
  File "mediapipe\python\solutions\hands.py", line 114, in __init__
  File "mediapipe\python\solution_base.py", line 234, in __init__
FileNotFoundError: The path does not exist: C:\Users\Administrator\Downloads\dist\22\_internal\mediapipe/modules/hand_landmark/hand_landmark_tracking_cpu.binarypb




https://fishc.com.cn/thread-226531-1-1.html
https://fishc.com.cn/thread-226531-1-1.html

https://fishc.com.cn/thread-226531-1-1.html这个链接里面的
,将输出的路径中的__init__.py替换为模型文件的路径,并在代码中添加这个路径。

这个是要怎么操作,我是小白,研究了好半天没懂
最佳答案
6 天前
解决MediaPipe模型路径问题的步骤:

1. 找到模型文件位置
打开Python安装目录,找到:
Lib\site-packages\mediapipe\modules\hand_landmark
复制其中的 hand_landmark_tracking_cpu.binarypb 文件

2. 修改代码路径
在调用 Hands() 的地方添加模型路径参数:

  1. from mediapipe.python.solutions import hands

  2. hands.Hands(
  3.     model_path=r'mediapipe/modules/hand_landmark/hand_landmark_tracking_cpu.binarypb',
  4.     # 其他参数保持不变...
  5. )
复制代码


3. 打包时添加资源文件(以pyinstaller为例):
创建spec文件时添加:

  1. a = Analysis(
  2.     ...
  3.     datas=[
  4.         ('源文件路径\\hand_landmark_tracking_cpu.binarypb', 'mediapipe/modules/hand_landmark')
  5.     ],
  6.     ...
  7. )
复制代码


4. 推荐目录结构
  • dist/
  • └── your_exe/
  •     ├── mediapipe/
  •     │   └── modules/
  •     │       └── hand_landmark/
  •     │           └── hand_landmark_tracking_cpu.binarypb
  •     └── your_exe.exe


5. 终极解决方案
如果仍然报错,直接将模型文件复制到报错提示的路径:
C:\Users\...\dist\22\_internal\mediapipe\modules\hand_landmark\

建议使用虚拟环境打包,避免路径污染。如果仍不成功,可以尝试更新mediapipe到最新版本

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 6 天前 | 显示全部楼层    本楼为最佳答案   
解决MediaPipe模型路径问题的步骤:

1. 找到模型文件位置
打开Python安装目录,找到:
Lib\site-packages\mediapipe\modules\hand_landmark
复制其中的 hand_landmark_tracking_cpu.binarypb 文件

2. 修改代码路径
在调用 Hands() 的地方添加模型路径参数:

  1. from mediapipe.python.solutions import hands

  2. hands.Hands(
  3.     model_path=r'mediapipe/modules/hand_landmark/hand_landmark_tracking_cpu.binarypb',
  4.     # 其他参数保持不变...
  5. )
复制代码


3. 打包时添加资源文件(以pyinstaller为例):
创建spec文件时添加:

  1. a = Analysis(
  2.     ...
  3.     datas=[
  4.         ('源文件路径\\hand_landmark_tracking_cpu.binarypb', 'mediapipe/modules/hand_landmark')
  5.     ],
  6.     ...
  7. )
复制代码


4. 推荐目录结构
  • dist/
  • └── your_exe/
  •     ├── mediapipe/
  •     │   └── modules/
  •     │       └── hand_landmark/
  •     │           └── hand_landmark_tracking_cpu.binarypb
  •     └── your_exe.exe


5. 终极解决方案
如果仍然报错,直接将模型文件复制到报错提示的路径:
C:\Users\...\dist\22\_internal\mediapipe\modules\hand_landmark\

建议使用虚拟环境打包,避免路径污染。如果仍不成功,可以尝试更新mediapipe到最新版本

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

 楼主| 发表于 6 天前 | 显示全部楼层
FishC 发表于 2025-5-14 19:21
解决MediaPipe模型路径问题的步骤:

1. 找到模型文件位置:

您好,我是小白,我还是有点不太明白,这步是要怎么操作?直接将模型文件复制到报错提示的路径:
C:\Users\...\dist\22\_internal\mediapipe\modules\hand_landmark\

模型文件是(Lib\site-packages\mediapipe\modules\hand_landmark
复制其中的 hand_landmark_tracking_cpu.binarypb 文件)这个吗,复制之后,点到 File "2.py", line 22, in <module>
  File "cvzone\HandTrackingModule.py", line 36, in __init__
  File "mediapipe\python\solutions\hands.py", line 114, in __init__
  File "mediapipe\python\solution_base.py", line 234, in __init__
这些py文件里面吗
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-5-20 18:56

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表