Python 2.7
Ubuntu 12.04
我正在尝试创建我编写的程序的可执行文件,它需要做的第一件事是创建一个目录,当运行源代码时它工作正常,当我创建可执行文件时出现以下错误:
[Errno 13] Permission denied: '/"folder_name"'
创建文件夹的代码:
def create_folder(self, user_input):
"""create base folder"""
splitput = user_input.split('=')
fold_title = splitput[-1]
try:
print 'making folder'
os.mkdir('/'+fold_title, 0777)
print 'made folder'
except Exception as e:
print e
print 'failed to create folder'
returned_path = '/'+fold_title+'/'
returned_path = '/'+fold_title+'/'
print returned_path
return returned_path
最佳答案
当前用户无权在“/”下创建目录。并且变量“fold_title”中有引号,请检查一下路径中是否确实需要引号。
关于python - 创建可执行文件后,pyinstaller mkdir 功能将不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20017177/