pyinstaller 无法正确导出PyQt5 Qt5*.dll组件
2019-08-26 python 2158

import os, shutil
import re
def convert_path(path):
seps = r'\/'
sep_other = seps.replace(os.sep, '')
return path.replace(sep_other, os.sep)
def list_dir(path):
dirs = []
for path, name, filenames in os.walk(path):
print(path)
dirs.append(path)
return dirs
def repairQt5(path):
bin_path = r'/PyQt5/Qt/bin'
dst = convert_path(path + bin_path)
for file in os.listdir(path):
try:
m = re.match("Qt5\w+\.dll", file)
if m:
f = os.path.join(path, file)
d = os.path.join(dst, file)
shutil.move(f, d)
print("move: %s -> %s" % (f, d))
except Exception as e:
print(str(e))
print("#====== 修复 pyinstaller 无法正确导入 Qt5 dll组件问题 ======")
def copyapp(conf_files, path,distpath):
if len(conf_files) > 0:
for file in conf_files:
f = os.path.join(path, file)
d = os.path.join(distpath, file)
if os.path.exists(d) == False:
if os.path.isdir(f):
shutil.copytree(f, d)
else:
shutil.copyfile(f, d)
print("copy: %s -> %s" % (f, d))
print("#====== 导入配置文件 ======")
def main():
path = os.getcwd()
print(path)
distpath = os.path.join(path, "dist")
# 导入 设定的内容
conf_files = [
'mp3.png',
'static'
]
for dir in os.listdir(distpath):
dtpath = os.path.join(distpath, dir)
if os.path.isdir(dtpath):
# 处理配置文件
copyapp(conf_files, path,dtpath)
# 修复 pyinstaller 无法正确导入 Qt5 dll组件问题
repairQt5(dtpath)
if __name__ == "__main__":
main() 很赞哦! (0)
相关文章
文章评论
-
-
-
0条评论