cx_freeze使得__file__路径解析错误

IOError: [Errno 20] Not a directory: '/storage/workspace/mediaFileAnalyzer/build/exe.linux-x86_64-2.7/lib/library.zip/orig-prefix.txt'

解决办法是,修改获取当前目录的方法 

def get__dir__():
    if getattr(sys, 'frozen', False):
        # frozen
        dir_ = os.path.dirname(sys.executable)
    else:
        # unfrozen
        dir_ = os.path.dirname(os.path.realpath(__file__))

    return dir_


def virtual_install_main_packages():
    #f = open(os.path.join(os.path.dirname(__file__), 'orig-prefix.txt'))
    f = open(os.path.join(get__dir__(), 'orig-prefix.txt'))

你可能感兴趣的:(python)