小工具知识网

当前位置: 首页 > 行业知识 > 【Python】Pyinstaller打包sh文件报错[77353] Failed to execute script ‘GCN-TSA‘ due to unhandled exception解决方案

行业知识

【Python】Pyinstaller打包sh文件报错[77353] Failed to execute script ‘GCN-TSA‘ due to unhandled exception解决方案

2026-11-03 10:19:09 来源:互联网转载

【Python】pyinstaller打包sh文件报错[77353] Failed to execute script ‘GCN-TSA’ due to unhandled exception!

大家好 我是寸铁

总结了一篇【Python】pyinstaller打包sh文件报错[77353] Failed to execute script ‘GCN-TSA’ due to unhandled exception!解决方案✨

喜欢的小伙伴可以点点关注

前言

在使用pyinstaller打包sh文件后运行sh文件报错如下:

具体如下:

File "",line 1006,in _find_and_load_unlockedFile "",line 688,in _load_unlockedFile "PyInstaller/loader/pyimod02_importers.py",line 419,in exec_moduleFile "torch_geometric/nn/pool/select/__init_-.py",line 7,in File "",line 1027,in _find_and_loadFile "",line 1006,in _find_and_load_unlockedFile "",line 688, in _load_unlockedFile "PyInstaller/loader/pyimod02_importers.py",line 419,in exec_moduleFile "torch_geometric/nn/pool/select/base.py",line 68, in File "torch/jit/script.py",line 1375,in scriptFile "torch/jit/_recursive.py",line 59,in _compile_and_register_classFile "torch/jit/frontend.py",line 26ó,in get_jit_class_defFile "torch/_sources.py",line 32,in get_source_lines_and_fileISError: Can't get source for , TorchScript requires sour:access in order to carry out compilation, make sure original .py files are available.[77353] Failed to execute script 'GCN-TSA' due to unhandled exception!

解决方案

  • 在要打包的pytorch程序中的导入包的最上面添加如下代码:
    def script_method(fn, _rcb=None):    return fndef script(obj, optimize=True, _frames_up=0, _rcb=None):    return objimport torch.jitscript_method1 = torch.jit.script_methodscript1 = torch.jit.scripttorch.jit.script_method = script_methodtorch.jit.script = script

    如下:

    • 将上面的代码放在导入包的前面
      • 再重新使用pyinstaller打包sh文件
        pyinstaller --onefile xx.py

        • 最后,运行一下sh文件

          现在运行后的结果与之前的不同,看了一下是因为没有GPU,这个结果是对的,pytorch跑深度学习是需要GPU的,因此,需要把sh文件放到有GPU显卡的服务器。

          • 打包成sh后在有Gpu的服务器上跑深度学习
            ./test.sh

            成功跑起来!!!


            看到这里的小伙伴,恭喜你又掌握了一个技能

            希望大家能取得胜利,坚持就是胜利

            我是寸铁!我们下期再见


            往期好文

            保姆级教程

            【保姆级教程】Windows11下go-zero的etcd安装与初步使用

            【保姆级教程】Windows11安装go-zero代码生成工具goctl、protoc、go-zero

            【Go-Zero】手把手带你在goland中创建api文件并设置高亮


            报错解决

            【Go-Zero】Error: user.api 27:9 syntax error: expected ‘:‘ | ‘IDENT‘ | ‘INT‘, got ‘(‘ 报错解决方案及api路由注意事项

            【Go-Zero】Error: only one service expected goctl一键转换生成rpc服务错误解决方案

            【Go-Zero】【error】 failed to initialize database, got error Error 1045 (28000):报错解决方案

            【Go-Zero】Error 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)报错解决方案

            【Go-Zero】type mismatch for field “Auth.AccessSecret“, expect “string“, actual “number“报错解决方案

            【Go-Zero】Error: user.api 30:2 syntax error: expected ‘)‘ | ‘KEY‘, got ‘IDENT‘报错解决方案

            【Go-Zero】Windows启动rpc服务报错panic:context deadline exceeded解决方案


            Go面试向

            【Go面试向】defer与time.sleep初探

            【Go面试向】defer与return的执行顺序初探

            【Go面试向】Go程序的执行顺序

            【Go面试向】rune和byte类型的认识与使用

            【Go面试向】实现map稳定的有序遍历的方式

上一篇:传奇服务器照片怎么看?

下一篇:服务器远程怎么还原系统?