解决在使用pyinstaller打包pytorch脚本的情况下遇到could not get source code的问题
这个问题折磨了我两天,终于找到了解决的办法,啊!
遇到的问题如下:
Traceback (most recent call last):
File "site-packages\torch\_utils_internal.py", line 46, in get_source_lines_and_file
File "inspect.py", line 936, in getsourcelines
File "inspect.py", line 767, in findsource
OSError: could not get source code
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "prediction.py", line 4, in <module>
import torch
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib.