失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > pyinstaller 打包python程序为可执行exe文件 js报错问题

pyinstaller 打包python程序为可执行exe文件 js报错问题

时间:2024-01-09 05:28:29

相关推荐

pyinstaller 打包python程序为可执行exe文件 js报错问题

pyinstaller 打包python程序为可执行exe文件,js报错问题

错误描述1 删除原来生成的东西2 使用半打包命令3 将刚才不能打包进去的依赖包的文件夹手动放入ui.exe所在的文件夹,一般在dist下(也可能还有一层文件夹)4 再次尝试打开ui,应该就可以了。参考

错误描述

工作需要,想把一个py文件转换成可执行exe文件,正常使用pyinstaller ui_app.py --onefile --icon=app_icon.ico转换后,打开dist文件夹内的exe文件,出现闪退现象,报错提示一下内容。

Traceback (most recent call last):File "ui.py", line 6, in <module>File "<frozen importlib._bootstrap>", line 1007, in _find_and_loadFile "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 680, in _load_unlockedFile "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_moduleFile "mne\__init__.py", line 99, in <module>from .report import Report, open_reportFile "<frozen importlib._bootstrap>", line 1007, in _find_and_loadFile "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 680, in _load_unlockedFile "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_moduleFile "mne\report\__init__.py", line 1, in <module>from .report import Report, open_report, _ReportScraperFile "<frozen importlib._bootstrap>", line 1007, in _find_and_loadFile "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 680, in _load_unlockedFile "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_moduleFile "mne\report\report.py", line 101, in <module>JAVASCRIPT = (html_include_dir / 'report.js').read_text(encoding='utf-8')File "pathlib.py", line 1266, in read_textFile "pathlib.py", line 1252, in openFile "pathlib.py", line 1120, in _openerFileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\userName\\AppData\\Local\\Temp\\_MEI208682\\mne\\report\\js_and_css\\report.js

问了问Chatgpt:

它告诉我以下方法:

This error suggests that the executable file is unable to find the report.js file required by the mne module. It seems that the file is not being included in the executable. You can try the following solutions to fix the issue:

Specify the --add-data option while running the PyInstaller command. For example, if the report.js file is located in the mne/report/js_and_css/ directory, you can add the following option:–add-data “mne/report/js_and_css/report.js;./mne/report/js_and_css/”. This tells PyInstaller to include the report.js file in the executable.

If the above solution does not work,you can manually copy the report.js file to the dist directory after building the executable.You can find the dist directory in the same directory where your Python script is located. Once you copy the file, try running the executable again.

If none of the above solutions work, you can try using the --onefile option while running the PyInstaller command. This will create a single executable file instead of multiple files, which might help in resolving the issue.

I hope one of these solutions helps you to fix the issue.

尝试无果。

后面看到CSDN上的一篇博客:/weixin_43865152/article/details/93781051

提到了他是如何解决的。

1 删除原来生成的东西

2 使用半打包命令

pyinstaller -D -w -i app_icon.ico ui.py

-w,是只打开ui界面,不显示cmd命令行。

-i,是加载图标

3 将刚才不能打包进去的依赖包的文件夹手动放入ui.exe所在的文件夹,一般在dist下(也可能还有一层文件夹)

例如将:

D:\anaconda\envs\DataManage\Lib\site-packages\mne_bids

D:\anaconda\envs\DataManage\Lib\site-packages\mne

放入 C:\Users\suername\PycharmProjects\Manage_project\dist

4 再次尝试打开ui,应该就可以了。

参考

/huhu1986/article/details/109388027

/weixin_43865152/article/details/93781051

如果觉得《pyinstaller 打包python程序为可执行exe文件 js报错问题》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。