简体   繁体   中英

pyinstaller mkdir function won't work after creating executable

Python 2.7

Ubuntu 12.04

I'm trying to create an executable of a program I have written, the first thing it needs to do is create a directory, when running the source code it works perfectly, when I create an executable I get the following error:

[Errno 13] Permission denied: '/"folder_name"'

The code for creating the folder:

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

The current user has no privilege to create a directory under "/". And there are qoutation marks in varible "fold_title", check it out if you really need qoutation marks in the path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM