如何修复subprocess.call()错误:WindowsError:[错误5]访问被拒绝?

时间:2017-11-21 01:30:35

标签: python command subprocess call windowserror

您好!

我试图让subprocess.call()将当前驱动器更改为C:但它给了我一个WindowsError,说明访问被拒绝。这是完整的错误:

from tkinter import *
from tkinter import filedialog
from subprocess import *
import shutil

root = Tk()
root.title("Snake converter")
def open_file():

    filename = filedialog.askopenfilename(filetypes = (("Snake files", "*.sim"),("Python Files", "*.py"),("All files", "*.*")))
    filenametmp = filename + ".tmp"
    print filename + " is being compiled. Please wait..."
    tf = open(filenametmp, "a")
    f = open(filename, "r")
    filecontents = f.read()
    tf.write("from simincmodule import *" + "\n")
    tf.write(filecontents)
    call("C:")
    call("cd C:\Snake\info\Scripts")
    f.close()
    tf.close()
    print "Done compiling " + filename + ". Find the file under /dist/[filename]/[filename].exe"

openbutton = Button(root, text = "Open", width = 10, command = open_file)
openbutton.pack()

root.mainloop() 

这是我的代码:

{{1}}

任何给予的帮助,甚至是建议,都将受到赞赏。

提前致谢!

0 个答案:

没有答案