转换为exe文件shutil python后,无法复制文件
我一直在尝试复制用于启动文件夹的Python脚本。一切都可以正常工作,但是在将脚本编译到.exe文件中后,我总是会遇到此错误:
File "shutil.py", line 417, in copy
File "shutil.py", line 254, in copyfile
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\x\\AppData\\Local\\Temp\\_MEI187322\\script.exe'
这是代码:
pathFile = os.path.join("C:\\", "Users", os.getlogin(), "AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup", "script.exe")
pathCurrent = os.path.realpath(__file__)
if pathCurrent != pathFile:
try:
shutil.copy(pathCurrent, pathFile)
except shutil.SameFileError:
pass
else:
pass
I've been trying to copy python script, that I use to startup folder. Everything works as it should, BUT after I compile the script into .exe file, I always get this error:
File "shutil.py", line 417, in copy
File "shutil.py", line 254, in copyfile
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\x\\AppData\\Local\\Temp\\_MEI187322\\script.exe'
This is the code:
pathFile = os.path.join("C:\\", "Users", os.getlogin(), "AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup", "script.exe")
pathCurrent = os.path.realpath(__file__)
if pathCurrent != pathFile:
try:
shutil.copy(pathCurrent, pathFile)
except shutil.SameFileError:
pass
else:
pass
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论