[英]After using pyinstaller to make my program into an exe, selenium stops working
[英]python script not working after using pyinstaller to make it .exe
path = os.path.realpath(__file__)
try:
shutil.move(path, "C:\\Users\\pc\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup")
except:
pass
try:
if os.path.exists("C:\\Users\\pc\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\{}".format(os.path.basename(__file__))):
os.remove(path)
except:
pass
使用pyinstaller之后,我在python中的整个代码块不再起作用,因此不会将文件移至目标位置。 请记住,它仅通过运行python脚本即可工作,因此我如何使其适应于使用pyinstaller使其成为.exe文件(有效的文件)
__file__
仍指向脚本名称,该名称已解压缩到一个临时目录中。
PyInstaller和Py2exe都将sys.executable覆盖到应用程序的路径,例如: C:\\Programs\\myApplication\\app.exe
。
您可能需要浏览文档以获取详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.