FileNotFoundError [Errno 2] when running pyinstaller executable?

◇◆丶佛笑我妖孽 提交于 2021-02-08 10:35:10

问题


I am trying to make my python file as an executable using Pyinstaller. After the process of conversion has finished, in my dist folder, when I click on "myApplication.exe" I get the following error: FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\user\\Desktop\\Application\\dist\\myApplication\\smart_open\\VERSION' [17416] Failed to execute script myApplication

I've already searched for answers to this but none of them have the specific error as mine which is the folder smart_open\VERSION as I have no idea what that's supposed to be.

EDIT

The smart_open folder does not even exists in my myApplication folder


回答1:


I think you have to add the VERSION file of smart_open in the spec file. More information in the documentation.

Edit

In this case, datas line should be:

datas=[ ('c:\\python360564\\lib\\site-packages\\smart_open\\VERSION', 'smart_open\\VERSION' )], 

The first part is the initial path of the file and the second the destination path (get from the error message).




回答2:


Instead of using the original version of "smart_open" use this fork of the library: https://github.com/rs-trevor/smart_open

The pull request is here: https://github.com/RaRe-Technologies/smart_open/pull/344

It essentially converts the strange (extension-less) "VERSION" file into "version.py" so pyinstaller picks it up correctly

I encountered the same issue posted it within the smart_open github: https://github.com/RaRe-Technologies/smart_open/issues/345



来源:https://stackoverflow.com/questions/57482672/filenotfounderror-errno-2-when-running-pyinstaller-executable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!