[英]Pyinstaller-compiled exe can't find file with absolute path
I compiled my Python GUI with Pyinstaller on Windows 10 but it seems like it cannot find my other script even though I provided the hard-coded absolute path to it (with r'"C:\\Program Files...script path..."'). 我在Windows 10上使用Pyinstaller编译了Python GUI,但即使我提供了它的硬编码绝对路径(带有r'“ C:\\ Program Files ... script path ...),它似乎也找不到我的其他脚本。 “”)。 I even tried os.isfile (script path) but it returns False.
我什至尝试了os.isfile(脚本路径),但返回False。 The python script was compiled with
pyinstaller --onefile --windowed --icon=iconimage.ico myscript.py
from the command prompt. python脚本是使用
pyinstaller --onefile --windowed --icon=iconimage.ico myscript.py
从命令提示符下编译的。 I use this same command on Ubuntu and the binary works just fine. 我在Ubuntu上使用了相同的命令,二进制文件也很好。 I read something about Pyinstaller creating a temporary directory which I found, but I don't think it matters where it's running from as long as I give it the full path, so I'm thinking maybe I need more options when compiling?
我读到一些有关Pyinstaller创建一个临时目录的信息,但是我认为只要在运行时提供完整路径就无关紧要,所以我想也许在编译时我需要更多选项吗? The GUI opens just fine.
GUI打开就好了。 It's when it needs to call the script that it doesn't do anything.
当它需要调用脚本时,它什么也不做。 There are no errors when I run it from the command prompt.
从命令提示符运行它时没有错误。 Please help!
请帮忙!
通过添加--onedir
可以解决--onedir
,它将把运行程序所需的所有内容都放在dist文件夹的一个目录中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.