brentvollebregt / auto-py-to-exe

Converts .py to .exe using a simple graphical interface
MIT License
3.99k stars 681 forks source link

ModuleNotFoundError for our custom package #202

Closed sezanzeb closed 3 years ago

sezanzeb commented 3 years ago

pyqt5 is in the output directory, but not our custom packages that we have installed locally.

Both are imported in the file that we selected. We added the package name to hidden-import with no avail. Running the exe shows ModuleNotFoundError.

Running auto-py-to-exe v2.10.0
Building directory: C:\Users\FOO~1\AppData\Local\Temp\tmpdv4ww9jb
Provided command: pyinstaller --noconfirm --onedir --windowed --icon "C:/Users/Foo/Documents/Python Scripts/Battery Calculator/batterycalculator/assets/batterie.ico" --hidden-import "batterycalculator" "C:/Users/Foo/Documents/Python Scripts/Battery Calculator/bin/main.py"
Recursion Limit is set to 5000
Executing: pyinstaller --noconfirm --onedir --windowed --icon C:/Users/Foo/Documents/Python Scripts/Battery Calculator/batterycalculator/assets/batterie.ico --hidden-import batterycalculator C:/Users/Foo/Documents/Python Scripts/Battery Calculator/bin/main.py --distpath C:\Users\FOO~1\AppData\Local\Temp\tmpdv4ww9jb\application --workpath C:\Users\FOO~1\AppData\Local\Temp\tmpdv4ww9jb\build --specpath C:\Users\FOO~1\AppData\Local\Temp\tmpdv4ww9jb

1359338 INFO: PyInstaller: 4.5.1
1359341 INFO: Python: 3.8.5 (conda)
1359344 INFO: Platform: Windows-10-10.0.19041-SP0
1359357 INFO: wrote C:\Users\FOO~1\AppData\Local\Temp\tmpdv4ww9jb\main.spec
1359375 INFO: UPX is not available.
1359392 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Foo\\Documents\\Python Scripts\\Battery '
'Calculator\\bin',
'C:\\Users\\FOO~1\\AppData\\Local\\Temp\\tmpdv4ww9jb']
1359861 INFO: checking Analysis
1359871 INFO: Building Analysis because Analysis-04.toc is non existent
1359886 INFO: Reusing cached module dependency graph...
1360010 INFO: Caching module graph hooks...
1360238 INFO: running Analysis Analysis-04.toc
1360243 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by C:\Users\Foo\anaconda3\python.exe
1360504 INFO: Analyzing C:\Users\Foo\Documents\Python Scripts\Battery Calculator\bin\main.py
1360575 INFO: Processing module hooks...
1360587 INFO: Loading module hook 'hook-difflib.py' from 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
1360604 INFO: Loading module hook 'hook-distutils.py' from 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
1360617 INFO: Loading module hook 'hook-distutils.util.py' from 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
1360634 INFO: Loading module hook 'hook-encodings.py' from 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
1360734 INFO: Loading module hook 'hook-heapq.py' from 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
1360738 INFO: Loading module hook 'hook-lib2to3.py' from 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
1360767 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
1360773 INFO: Loading module hook 'hook-pickle.py' from 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
1360779 INFO: Loading module hook 'hook-PyQt5.py' from 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
1360813 INFO: Loading module hook 'hook-PyQt5.QtCore.py' from 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
1360885 INFO: Loading module hook 'hook-PyQt5.QtGui.py' from 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
1361018 INFO: Loading module hook 'hook-PyQt5.QtWidgets.py' from 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
1361211 INFO: Loading module hook 'hook-sysconfig.py' from 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
1361226 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
1361231 INFO: Loading module hook 'hook-xml.py' from 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
1361339 INFO: Loading module hook 'hook-_tkinter.py' from 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks'...
1361498 INFO: checking Tree
1361505 INFO: Building Tree because Tree-12.toc is non existent
1361521 INFO: Building Tree Tree-12.toc
1361572 INFO: checking Tree
1361582 INFO: Building Tree because Tree-13.toc is non existent
1361585 INFO: Building Tree Tree-13.toc
1361699 INFO: checking Tree
1361706 INFO: Building Tree because Tree-14.toc is non existent
1361722 INFO: Building Tree Tree-14.toc
1361749 INFO: Looking for ctypes DLLs
1361764 INFO: Analyzing run-time hooks ...
1361786 INFO: Including run-time hook 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
1361796 INFO: Including run-time hook 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
1361818 INFO: Including run-time hook 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
1361831 INFO: Including run-time hook 'C:\\Users\\Foo\\anaconda3\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pyqt5.py'
1361850 INFO: Looking for dynamic libraries
1362623 INFO: Looking for eggs
1362626 INFO: Using Python library C:\Users\Foo\anaconda3\python38.dll
1362645 INFO: Found binding redirects:
[]
1362660 INFO: Warnings written to C:\Users\FOO~1\AppData\Local\Temp\tmpdv4ww9jb\build\main\warn-main.txt
1362707 INFO: Graph cross-reference written to C:\Users\FOO~1\AppData\Local\Temp\tmpdv4ww9jb\build\main\xref-main.html
1362734 INFO: checking PYZ
1362739 INFO: Building PYZ because PYZ-04.toc is non existent
1362742 INFO: Building PYZ (ZlibArchive) C:\Users\FOO~1\AppData\Local\Temp\tmpdv4ww9jb\build\main\PYZ-04.pyz
1363430 INFO: Building PYZ (ZlibArchive) C:\Users\FOO~1\AppData\Local\Temp\tmpdv4ww9jb\build\main\PYZ-04.pyz completed successfully.
1363457 INFO: checking PKG
1363474 INFO: Building PKG because PKG-04.toc is non existent
1363490 INFO: Building PKG (CArchive) PKG-04.pkg
1363537 INFO: Building PKG (CArchive) PKG-04.pkg completed successfully.
1363541 INFO: Bootloader C:\Users\Foo\anaconda3\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
1363553 INFO: checking EXE
1363559 INFO: Building EXE because EXE-04.toc is non existent
1363569 INFO: Building EXE from EXE-04.toc
1363588 INFO: Copying icons from ['C:\\Users\\Foo\\Documents\\Python Scripts\\Battery Calculator\\batterycalculator\\assets\\batterie.ico']
1363665 INFO: Writing RT_GROUP_ICON 0 resource with 20 bytes
1363669 INFO: Writing RT_ICON 1 resource with 6083 bytes
1363691 INFO: Appending archive to EXE C:\Users\FOO~1\AppData\Local\Temp\tmpdv4ww9jb\build\main\main.exe
1364264 INFO: Building EXE from EXE-04.toc completed successfully.
1364275 INFO: checking COLLECT
1364288 INFO: Building COLLECT because COLLECT-04.toc is non existent
1364303 INFO: Removing dir C:\Users\FOO~1\AppData\Local\Temp\tmpdv4ww9jb\application\main
1364383 INFO: Building COLLECT COLLECT-04.toc
1365234 INFO: Building COLLECT COLLECT-04.toc completed successfully.

Moving project to: C:\Users\Foo\Desktop\Battery Calculator
Complete.

main.py:

from PyQt5 import QtCore, QtGui, QtWidgets

from batterycalculator.mainwindow import MainWindow

if __name__ == "__main__":
    import sys

    app = QtWidgets.QApplication(sys.argv)
    q_main_window = QtWidgets.QMainWindow()
    ui = MainWindow()
    ui.setupUi(q_main_window)
    q_main_window.show()
    sys.exit(app.exec_())

the batterycalculator package is installed on the system via pip and can be imported from the command line.

sezanzeb commented 3 years ago

It was probably because batterycalculator was not installed from within the anaconda environment, but rather in the default python paths. conda prompt, then install the missing package via pip.

I'll close it for now, other issues popped up with the environment in the meantime that we need to fix first. If the issue still persists I'll reopen.