Re: PyInstaller
Verfasst: Mittwoch 24. Juli 2019, 15:00
Probier beim zweiten Argument / statt \ zu benutzen.
Seit 2002 Diskussionen rund um die Programmiersprache Python
https://www.python-forum.de/
Okay wenn es 50MB werden wäre es also auch kein Problem.sparrow hat geschrieben: Donnerstag 25. Juli 2019, 08:03 Dann schau doch mal nach, was da alles in das Archiv wandert.
Während das Programm läuft, wird der Inhalt ja temporär entpackt.
Wenn ich mich richtig erinnere, hat ein Programm mit QT und Python-Interpreter unter 30 MB. Da scheinen bei dir also viel mehr Dinge eingesammelt zu werden. Aber das können wir ohne Glaskugel nicht beantworten.
Code: Alles auswählen
--onedir
Code: Alles auswählen
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['ascFileReader_V2.5.py'],
pathex=['C:\\Users\\stf83wi\\Desktop\\Test_asc'],
binaries=[],
datas=[('C:\\Python37\\Lib\\site-packages\\plotly\\package_data\\templates\\plotly.json', 'plotly\\package_data\\templates'), ('C:\\Python37\\Lib\\site-packages\\plotly\\package_data\\plotly.min.js', 'plotly\\package_data')],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='ascFileReader_V2.5',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False , icon='asc.ico')
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='ascFileReader_V2.5')
Code: Alles auswählen
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['ascFileReader_V2.5.py'],
pathex=['C:\\Users\\stf83wi\\Desktop\\asc_Test'],
binaries=[],
datas=[('C:\\Python37\\Lib\\site-packages\\plotly\\package_data\\templates\\plotly.json', 'plotly\\package_data\\templates'), ('C:\\Python37\\Lib\\site-packages\\plotly\\package_data\\plotly.min.js', 'plotly\\package_data')],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='ascFileReader_V2.5',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True , icon='asc.ico')
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='ascFileReader_V2.5')
Die exe Datei hat legendlich 23MBmkl_core.dll mit 68MB
mkl_avx512.dll mit 59MB
mkl_avx2.dll mit 45MB
mkl_avx.dll mit 42MB
mkl_mc3.dll mit 41MB
mkl_mc.dll mit 40MB
mkl_def.dll mit 34MB
Code: Alles auswählen
pyinstaller ascFileReader_V2.5.py --add-data "C:\Python37\Lib\site-packages\plotly\package_data\templates\plotly.json;plotly\package_data\templates" --add-data "C:\Python37\Lib\site-packages\plotly\package_data\plotly.min.js;plotly\package_data" --add-data "C:\Program Files\Anaconda3\Lib\site-packages\PyQt5\Qt\bin\Qt5Core.dll;bin\Qt\PyQt5" --icon=asc.ico --onedir
Code: Alles auswählen
144 INFO: PyInstaller: 3.5
144 INFO: Python: 3.7.4
147 INFO: Platform: Windows-10-10.0.17763-SP0
151 INFO: wrote C:\Users\stf83wi\Desktop\asc_Test\ascFileReader_V2.5.spec
153 INFO: UPX is not available.
159 INFO: Extending PYTHONPATH with paths
['C:\\Users\\stf83wi\\Desktop\\asc_Test',
'C:\\Users\\stf83wi\\Desktop\\asc_Test']
159 INFO: checking Analysis
162 INFO: Building Analysis because Analysis-00.toc is non existent
162 INFO: Initializing module dependency graph...
173 INFO: Initializing module graph hooks...
178 INFO: Analyzing base_library.zip ...
3616 INFO: running Analysis Analysis-00.toc
3620 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\python37\python.exe
6380 INFO: Caching module hooks...
6387 INFO: Analyzing C:\Users\stf83wi\Desktop\asc_Test\ascFileReader_V2.5.py
6505 INFO: Processing pre-find module path hook distutils
7116 INFO: Processing pre-find module path hook site
7117 INFO: site: retargeting to fake-dir 'c:\\python37\\lib\\site-packages\\PyInstaller\\fake-modules'
10231 INFO: Processing pre-safe import module hook six.moves
42808 INFO: Loading module hooks...
42808 INFO: Loading module hook "hook-distutils.py"...
42817 INFO: Loading module hook "hook-encodings.py"...
42982 INFO: Loading module hook "hook-matplotlib.backends.py"...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\python37\lib\site-packages\matplotlib\__init__.py", line 138, in <module>
from . import cbook, rcsetup
File "c:\python37\lib\site-packages\matplotlib\cbook\__init__.py", line 31, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
43217 INFO: Loading module hook "hook-matplotlib.py"...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\python37\lib\site-packages\matplotlib\__init__.py", line 138, in <module>
from . import cbook, rcsetup
File "c:\python37\lib\site-packages\matplotlib\cbook\__init__.py", line 31, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
43472 INFO: Loading module hook "hook-pandas.py"...
43723 INFO: Loading module hook "hook-pkg_resources.py"...
44224 INFO: Processing pre-safe import module hook win32com
Traceback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'win32com'
44361 INFO: Processing pre-safe import module hook win32com
Traceback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'win32com'
44635 INFO: Loading module hook "hook-pydoc.py"...
44637 INFO: Loading module hook "hook-PyQt5.py"...
44923 INFO: Loading module hook "hook-PyQt5.QtCore.py"...
46724 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
49154 INFO: Loading module hook "hook-PyQt5.QtWidgets.py"...
52813 INFO: Loading module hook "hook-pytz.py"...
53024 INFO: Loading module hook "hook-sqlite3.py"...
53198 INFO: Loading module hook "hook-sysconfig.py"...
53200 INFO: Loading module hook "hook-xml.dom.domreg.py"...
53201 INFO: Loading module hook "hook-xml.py"...
53306 INFO: Looking for ctypes DLLs
53338 INFO: Analyzing run-time hooks ...
53352 INFO: Including run-time hook 'pyi_rth_mplconfig.py'
53357 INFO: Including run-time hook 'pyi_rth_mpldata.py'
53358 INFO: Including run-time hook 'pyi_rth_pkgres.py'
53360 INFO: Including run-time hook 'pyi_rth_pyqt5.py'
53398 INFO: Looking for dynamic libraries
104588 INFO: Looking for eggs
104588 INFO: Using Python library c:\python37\python37.dll
104591 INFO: Found binding redirects:
[]
104611 INFO: Warnings written to C:\Users\stf83wi\Desktop\asc_Test\build\ascFileReader_V2.5\warn-ascFileReader_V2.5.txt
104922 INFO: Graph cross-reference written to C:\Users\stf83wi\Desktop\asc_Test\build\ascFileReader_V2.5\xref-ascFileReader_V2.5.html
105025 INFO: Appending 'datas' from .spec
105038 INFO: checking PYZ
105038 INFO: Building PYZ because PYZ-00.toc is non existent
105039 INFO: Building PYZ (ZlibArchive) C:\Users\stf83wi\Desktop\asc_Test\build\ascFileReader_V2.5\PYZ-00.pyz
108859 INFO: Building PYZ (ZlibArchive) C:\Users\stf83wi\Desktop\asc_Test\build\ascFileReader_V2.5\PYZ-00.pyz completed successfully.
108930 INFO: checking PKG
108930 INFO: Building PKG because PKG-00.toc is non existent
108933 INFO: Building PKG (CArchive) PKG-00.pkg
108981 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
108984 INFO: Bootloader c:\python37\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
108984 INFO: checking EXE
108985 INFO: Building EXE because EXE-00.toc is non existent
108985 INFO: Building EXE from EXE-00.toc
108999 INFO: Copying icons from ['asc.ico']
109001 INFO: Writing RT_GROUP_ICON 0 resource with 20 bytes
109003 INFO: Writing RT_ICON 1 resource with 67624 bytes
109010 INFO: Appending archive to EXE C:\Users\stf83wi\Desktop\asc_Test\build\ascFileReader_V2.5\ascFileReader_V2.5.exe
109022 INFO: Building EXE from EXE-00.toc completed successfully.
109028 INFO: checking COLLECT
109029 INFO: Building COLLECT because COLLECT-00.toc is non existent
109034 INFO: Building COLLECT COLLECT-00.toc
113267 INFO: Building COLLECT COLLECT-00.toc completed successfully.
Code: Alles auswählen
PS C:\Users\stf83wi\Desktop\asc_Test\dist\ascFileReader_V2.5> .\ascFileReader_V2.5.exe
Traceback (most recent call last):
File "ascFileReader_V2.5.py", line 5, in <module>
File "c:\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\PyQt5\__init__.py", line 41, in <module>
File "site-packages\PyQt5\__init__.py", line 33, in find_qt
ImportError: unable to find Qt5Core.dll on PATH
[19640] Failed to execute script ascFileReader_V2.5
Code: Alles auswählen
--add-data "C:\Program Files\Anaconda3\Lib\site-packages\PyQt5\Qt\bin\Qt5Core.dll;bin\Qt\PyQt5"
Numpy habe ich mitsparrow hat geschrieben: Freitag 26. Juli 2019, 09:11 Offensichtlich verwendest du Anaconda und numpy:
https://stackoverflow.com/questions/492 ... -necessary
Code: Alles auswählen
pip uninstall numpy
Code: Alles auswählen
if self.ui.html_auto_open.isChecked():
self.var = True
else:
self.var = False
Code: Alles auswählen
self.var = self.ui.html_auto_open.isChecked()
Code: Alles auswählen
# Schneidet den nur Filenamen raus und speichert diesen in eine neue Variable
file_title = self.asc_filename[self.asc_filename.rfind('\\')+1:len(self.asc_filename)]
Code: Alles auswählen
file_title = os.path.basename(self.asc_filename)
Code: Alles auswählen
#!/usr/bin/env python3
from collections import namedtuple
import os
import sys
from functools import partial
import pandas as pd
import plotly
from plotly import graph_objects as go
from PyQt5 import QtWidgets
from ui.mainwindow import Ui_asc_File_Reader
MeasurementCategory = namedtuple(
'MeasurementCategory', 'name description id convert'
)
#
# TODO Die `lambda`\s lassen sich bestimmt auch als Daten ausdrücken.
#
MEASUREMENT_CATEGORIES = [
MeasurementCategory(
'ubatlogger',
'Ubatlogger',
'800200BA',
lambda x: x * (5 / 4095) * 8.655106
),
MeasurementCategory(
'pressure',
'Pressure',
'80083DCE',
lambda x: (x - 2) * 0.00257038 - 0.5
),
MeasurementCategory(
'temperature',
'Temperature',
'80083DA5',
lambda x: (x - 1) * 0.125 - 73.025
),
MeasurementCategory(
'concentration',
'Concentration',
'80083DEF',
lambda x: (x - 1) * 0.05 - 20
),
MeasurementCategory(
'level',
'Level',
'80083DD6',
lambda x: (x - 1) * 0.125
),
MeasurementCategory(
'speedofsound',
'Speed of Sound',
'80083E09',
lambda x: (x - 1) * 0.25 + 1000
),
]
class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle('Test')
self.ui = Ui_asc_File_Reader()
self.ui.setupUi(self)
self.ui.choose_button.clicked.connect(self.choose_asc_filename)
#
# TODO Die GUI-Elemente hier erstellen, statt sie hart kodiert in der
# *.ui-Datei anzulegen.
#
for number, category in enumerate(MEASUREMENT_CATEGORIES, 1):
button = getattr(self.ui, category.name)
button.clicked.connect(
partial(self.on_check_clicked, button, number)
)
self.ui.choose_button_2.clicked.connect(self.choose_target_path)
self.ui.export_to_html.clicked.connect(self.export_to_html)
self.ui.exit.clicked.connect(self.close)
self.asc_filename = None
self.target_path = None
def choose_asc_filename(self):
#
# TODO Nicht unnötig von Windows abhängig machen.
#
self.asc_filename, _ = QtWidgets.QFileDialog.getOpenFileName(
self, 'Open file', 'c:\\', 'Image files (*.asc)'
)
self.ui.Info1.setText(self.asc_filename)
def on_check_clicked(self, checkable, number):
getattr(self.ui, f'pass{number}').setText(
'YES' if checkable.isChecked() else 'NO'
)
def choose_target_path(self):
self.target_path = QtWidgets.QFileDialog.getExistingDirectory()
self.ui.Info2.setText(self.target_path)
def export_to_html(self):
if self.asc_filename is not None:
figure = go.Figure()
#
# TODO `skipinitialspace` kann den Zugriff auf die Spalten
# vielleicht etwas weniger fehleranfällig machen. Auf jeden Fall
# braucht man dann nicht mehr Leerzeichen bei den Namen zählen.
#
data = pd.read_csv(
self.asc_filename,
skiprows=5,
delimiter=';',
#
# FIXME Weglassen oder reparieren, denn das hat offensichtlich
# keinen Effekt.
#
converters={' DATA L': partial(int, base=16)},
)
file_title = os.path.basename(self.asc_filename)
font = dict(
family='Courier New, monospace', size=20, color='#7f7f7f'
)
figure.update_layout(
title=go.layout.Title(text=file_title, xref='paper', x=0),
xaxis=go.layout.XAxis(
title=go.layout.xaxis.Title(text='Second [s]', font=font)
),
yaxis=go.layout.YAxis(
title=go.layout.yaxis.Title(text='Values', font=font)
),
)
for category in MEASUREMENT_CATEGORIES:
if getattr(self.ui, category.name).isChecked():
selected_data = data[data[' DATA H'] == category.id]
times = selected_data[' Offset[s]']
values = selected_data[' DATA L'].apply(category.convert)
figure.add_trace(
go.Scatter(
x=times,
y=values,
mode='lines',
name=category.description,
)
)
filename = self.asc_filename
if self.target_path:
filename = os.path.join(
self.target_path, os.path.basename(filename)
)
plotly.offline.plot(
figure,
filename=filename + '.html',
auto_open=self.ui.html_auto_open.isChecked(),
)
def main():
app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()