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后报这个错
这个错误是由于在打包成exe文件时,无法获取到源代码导致的。你可以尝试以下方法解决这个问题:
确保你的代码中没有使用inspect
模块的getsource
或getsourcelines
函数,因为这些函数可能会引发错误。如果需要使用这些函数,可以考虑将它们替换为其他实现方式。
检查你的代码中是否有语法错误或其他问题,这可能导致在打包成exe文件时出现问题。你可以使用Python的pylint
工具来检查代码质量。
如果问题仍然存在,你可以尝试使用其他打包工具,如cx_Freeze
或PyOxidizer
,看看是否能解决问题。
这个错误是由于在打包成exe文件时,无法获取源代码导致的。你可以尝试以下方法解决这个问题:
确保你的代码中没有使用inspect
模块来获取源代码。如果有,请删除或注释掉相关代码。
检查你的代码中是否有使用到第三方库,这些库可能不支持PyInstaller打包。如果有,请尝试使用其他打包工具,如cx_Freeze或Nuitka。
如果问题仍然存在,你可以尝试在打包之前将需要使用的第三方库的源代码复制到打包后的exe文件所在的目录。这样,在运行时就可以找到这些库的源代码了。