Pyinstaller and Ply IOError: source code not available

前端 未结 2 1260
攒了一身酷
攒了一身酷 2021-01-25 10:04

I am pretty new to pyinstaller but I have been banging my head against this problem for a couple of days now and I can\'t seem to figure out what\'s wrong. My script runs fine n

相关标签:
2条回答
  • 2021-01-25 10:47

    it seems that with PLY it is necessary to include the py file itself as described on THIS link, the workaround solution is to add the file in the .spec file generated by pyinstaller as below :

    datas=[('calc.py','.')]
    

    see pyinstaller Using spec file for details on adding a file into your executable

    0 讨论(0)
  • 2021-01-25 11:11

    PLY insists that its grammars be defined in files. Real files, with names and everything. I think that's because of its strategy to cache the computed grammar tables, which involves comparing the timestamp of the cached tables with the timestamp of the original file.

    Pyinstaller is, apparently, evaluating the grammar as a <string>, since it is extracted from an archive rather than being a file. (The Pyinstaller manual mentions that __file__ is not correctly set for the frozen application, and that is what PLY is looking at.) You might try using the --onedir option when you create your installer bundle, but of course that has slightly different behaviour.

    0 讨论(0)
提交回复
热议问题