[英]python Pyinstaller IOError: [Errno 13] Permission denied
py2exe works good but pyinstaller make this errors py2exe 运行良好,但 pyinstaller 出现此错误
ERROR:utils:[Errno 13] Permission denied: 'C:\\Documents and Settings\\Administrator\\Application Data\\khan\\controll123.exe'
Traceback (most recent call last):
File "C:\Users\Philips\Desktop\filesync\filesyncbaaaaaaaaaaa\client\controll123\out00-PYZ.pyz\utils", line 94, in drop_check
File "C:\Users\Philips\Desktop\filesync\filesyncbaaaaaaaaaaa\client\controll123\out00-PYZ.pyz\shutil", line 88, in copy
File "C:\Users\Philips\Desktop\filesync\filesyncbaaaaaaaaaaa\client\controll123\out00-PYZ.pyz\shutil", line 53, in copyfile
IOError: [Errno 13] Permission denied: 'C:\\Documents and Settings\\Administrator\\Application Data\\khan\\controll123.exe'
here is my code这是我的代码
import os
import sys
from time import sleep
import random
import subprocess
import zipfile
from config import APPDATA
import shutil
import win32api, win32con
import _winreg
import logging
def register_startup(filename):
try:
key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",0, _winreg.KEY_ALL_ACCESS)
_winreg.SetValueEx(key, "KSSync",0, _winreg.REG_SZ, filename)
return True
except Exception, e:
return False
if not os.path.exists(APPDATA):
os.makedirs(APPDATA)
dest = os.path.join(APPDATA, "strong_%s.exe" % str(random.randrange(1000,9999)) )
logger.debug("Copying %s to %s" % (sys.executable, dest) )
shutil.copy(sys.executable, dest)
logger.info("Installed %s to %s" % (sys.executable, dest))
register_startup(dest)
subprocess.Popen([dest, '--patience'])
sys.exit(1)
return True
except Exception, e:
logger.exception(e)
return False
The call to register the file in startup These two function produce the error register_startup(dest) subprocess.Popen([dest, '--patience'])在启动时注册文件的调用这两个函数产生错误 register_startup(dest) subprocess.Popen([dest, '--patience'])
Yes The file is present C:\\Documents and Settings\\Administrator\\Application Data\\khan\\controll123.exe是 文件存在 C:\\Documents and Settings\\Administrator\\Application Data\\khan\\controll123.exe
seems the double back sash are REASON ?似乎双背窗框是原因?
Met this problem just now,刚刚遇到这个问题,
Solved by running the cmd
with admin mode.通过在管理员模式下运行
cmd
解决。
I encountered a similar problem when using pyinstaller, even running cmd as administrator didn't work (personal laptop).我在使用 pyinstaller 时遇到了类似的问题,即使以管理员身份运行 cmd 也不起作用(个人笔记本电脑)。 What work for me was:
对我来说什么工作是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.