开发者社区 > ModelScope模型即服务 > 计算机视觉 > 正文

在ModelScope中, 切换到要求的版本后。打包成exe后报这个错怎么办?

Traceback (most recent call last):
File "test_qt.py", line 15, in
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "special.py", line 38, in
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "mix.py", line 20, in
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "modelscope\pipelines__init.py", line 4, in
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "modelscope\pipelines\base.py", line 16, in
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "modelscope\msdatasets\
init.py", line 2, in
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "modelscope\msdatasets\ms_dataset.py", line 9, in
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "datasets\
init.py", line 52, in
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "datasets\inspect.py", line 30, in
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "datasets\load.py", line 58, in
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "datasets\packaged_modules\
init__.py", line 32, in
File "inspect.py", line 1139, in getsource
File "inspect.py", line 1121, in getsourcelines
File "inspect.py", line 958, in findsource
OSError: could not get source code
切换到要求的版本后。打包成exe后报这个错

展开
收起
崔问问 2023-12-03 23:01:22 189 0
2 条回答
写回答
取消 提交回答
  • 面对过去,不要迷离;面对未来,不必彷徨;活在今天,你只要把自己完全展示给别人看。

    这个错误是由于在打包成exe文件时,无法获取到源代码导致的。你可以尝试以下方法解决这个问题:

    1. 确保你的代码中没有使用inspect模块的getsourcegetsourcelines函数,因为这些函数可能会引发错误。如果需要使用这些函数,可以考虑将它们替换为其他实现方式。

    2. 检查你的代码中是否有语法错误或其他问题,这可能导致在打包成exe文件时出现问题。你可以使用Python的pylint工具来检查代码质量。

    3. 如果问题仍然存在,你可以尝试使用其他打包工具,如cx_FreezePyOxidizer,看看是否能解决问题。

    2023-12-04 14:52:55
    赞同 展开评论 打赏
  • 这个错误是由于在打包成exe文件时,无法获取源代码导致的。你可以尝试以下方法解决这个问题:

    1. 确保你的代码中没有使用inspect模块来获取源代码。如果有,请删除或注释掉相关代码。

    2. 检查你的代码中是否有使用到第三方库,这些库可能不支持PyInstaller打包。如果有,请尝试使用其他打包工具,如cx_Freeze或Nuitka。

    3. 如果问题仍然存在,你可以尝试在打包之前将需要使用的第三方库的源代码复制到打包后的exe文件所在的目录。这样,在运行时就可以找到这些库的源代码了。

    2023-12-04 14:13:51
    赞同 展开评论 打赏

包含图像分类、图像生成、人体人脸识别、动作识别、目标分割、视频生成、卡通画、视觉评价、三维视觉等多个领域

热门讨论

热门文章

相关电子书

更多
视觉AI能力的开放现状及ModelScope实战 立即下载
ModelScope助力语音AI模型创新与应用 立即下载
低代码开发师(初级)实战教程 立即下载