Search code examples
pythonpyarmor

Pyarmor .exe "can't find file" error after packing .py file


I packed my python file with this command: pyarmor pack --clean -e " --onefile --icon favicon.ico" myfile.py

But the problem is, after packing and running the .exe file. The program gives me the error:

[Errno 2] No such file or directory: './files/urls.txt'

Even though in the directory which I'm running the .exe there is a folder with the name "files" and in that folder there is a .txt file with the name "urls". How can I fix this error? Thanks for any help in advance.


Solution

  • I cannot give you the complete answer, only some pointer to help you, because I do not know the specifics of pyarmor.

    I would check where myfile.py "thinks" you are. This can be done with a print and a file (I think you can easily find the absolute path of . (dot) that is the current dir where you are)

    You can also print the absolute path of './files/urls.txt' to verify its existance. (see also the related question: how do I check wheather a file exists without exception)

    If that does not point in the right direction, please comment or edit your question to provide more details.