Skip to content

Commit

Permalink
pyinstaller failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexhaoge committed Jul 8, 2021
1 parent 14accd7 commit 5248de0
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,5 @@ nohup.out
*.nohup.out
/.vscode/
paper&slides/~$机器学习的经济困难生精准资助研究-大作业论文.docx
demo/build
demo/dist
File renamed without changes.
103 changes: 103 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion demo/MLSR_Demo.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import sys
from traceback import print_exc
from pandas import Series, DataFrame
from PyQt5.QtCore import QDir
from PyQt5.QtWidgets import QApplication, QMainWindow, QDialog, QFileDialog
from demo.page import *
from demo.pop import *
from MLSR.data import DataSet
from joblib import load
import sklearn
from sklearn.model_selection import GridSearchCV, train_test_split
from sklearn.preprocessing import MinMaxScaler
from sklearn.pipeline import Pipeline


class childWindow(QDialog):
Expand All @@ -30,6 +35,7 @@ def model_predict(self):
self.model_path = self.open_model()
self.model = load(self.model_path)
except Exception as e:
print_exc(e)
self.model = None
return
s = Series(dtype=object)
Expand Down Expand Up @@ -76,7 +82,7 @@ def model_predict(self):
self.resultArea.setText(ans_type[ans])
except Exception as e:
self.resultArea.setText('输入有误或模型导入错误\n请检查输入或重新导入模型')
print(e.__str__())
print_exc(e)

def open_model(self):
dig = QFileDialog()
Expand All @@ -92,6 +98,7 @@ def load_from_status_bar(self):
self.model_path = self.open_model()
self.model = load(self.model_path)
except Exception as e:
print_exc(e)
self.model = None

def open_github(self):
Expand Down
20 changes: 0 additions & 20 deletions demo/Pipfile.lock

This file was deleted.

10 changes: 10 additions & 0 deletions demo/hooks/hook-sklearn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from PyInstaller.utils.hooks import collect_all


def hook(hook_api):
packages = ['sklearn', 'numpy', 'scipy', 'pandas']
for package in packages:
datas, binaries, hiddenimports = collect_all(package)
# hook_api.add_datas(datas) # 注释掉是因为通常用不到
# hook_api.add_binaries(binaries)
hook_api.add_imports(*hiddenimports)

0 comments on commit 5248de0

Please sign in to comment.