Pyinstaller issue in packaging exe program on win10 - python

Currently i meet issue while packaging exe through pyinstaller .
I create a virtual environmental under pycharm , and my programe is very simple
a = input("please input a :")
b = input("please input b: ")
c = print(a+b)
the code stored in test.py . and then I type pyinstaller -F test.py on pycharm consle , it shows as below . as you seen , many libs not found , and packaing failed .
(venv) C:\cheng\Project\STC_Tool\venv>pyinstaller -v
3.6
(venv) C:\cheng\Project\STC_Tool\venv>pyinstaller -F test.py
67 INFO: PyInstaller: 3.6
67 INFO: Python: 3.7.8
70 INFO: Platform: Windows-10-10.0.18362-SP0
72 INFO: wrote C:\cheng\Project\STC_Tool\venv\test.spec
73 INFO: UPX is not available.
74 INFO: Extending PYTHONPATH with paths
['C:\\cheng\\Project\\STC_Tool\\venv', 'C:\\cheng\\Project\\STC_Tool\\venv']
75 INFO: checking Analysis
77 INFO: Building because C:\cheng\Project\STC_Tool\venv\test.py changed
78 INFO: Initializing module dependency graph...
80 INFO: Caching module graph hooks...
83 INFO: Analyzing base_library.zip ...
2178 INFO: Processing pre-find module path hook distutils
2191 INFO: distutils: retargeting to non-venv dir 'C:\\cheng\\Software\\Python\\lib'
3247 INFO: Caching module dependency graph...
3348 INFO: running Analysis Analysis-00.toc
3351 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\cheng\project\stc_tool\venv\scripts\python.exe
3365 WARNING: lib not found: VERSION.dll dependency of c:\cheng\project\stc_tool\venv\scripts\python.exe
3371 INFO: Analyzing C:\cheng\Project\STC_Tool\venv\test.py
3373 INFO: Processing module hooks...
3374 INFO: Loading module hook "hook-distutils.py"...
3375 INFO: Loading module hook "hook-encodings.py"...
3656 INFO: Loading module hook "hook-pydoc.py"...
3657 INFO: Loading module hook "hook-sysconfig.py"...
3659 INFO: Loading module hook "hook-xml.py"...
3910 INFO: Looking for ctypes DLLs
3915 INFO: Analyzing run-time hooks ...
3917 INFO: Looking for dynamic libraries
3937 WARNING: lib not found: VCRUNTIME140.dll dependency of C:\cheng\Software\Python\DLLs\select.pyd
3947 WARNING: lib not found: python37.dll dependency of C:\cheng\Software\Python\DLLs\select.pyd
3966 WARNING: lib not found: VCRUNTIME140.dll dependency of C:\cheng\Software\Python\DLLs\_socket.pyd
3974 WARNING: lib not found: python37.dll dependency of C:\cheng\Software\Python\DLLs\_socket.pyd
3978 WARNING: lib not found: VCRUNTIME140.dll dependency of C:\cheng\Software\Python\DLLs\_lzma.pyd
3994 WARNING: lib not found: python37.dll dependency of C:\cheng\Software\Python\DLLs\_lzma.pyd
4001 WARNING: lib not found: VCRUNTIME140.dll dependency of C:\cheng\Software\Python\DLLs\_bz2.pyd
4027 WARNING: lib not found: python37.dll dependency of C:\cheng\Software\Python\DLLs\_bz2.pyd
4052 WARNING: lib not found: VCRUNTIME140.dll dependency of C:\cheng\Software\Python\DLLs\_hashlib.pyd
4062 WARNING: lib not found: python37.dll dependency of C:\cheng\Software\Python\DLLs\_hashlib.pyd
4071 WARNING: lib not found: libcrypto-1_1.dll dependency of C:\cheng\Software\Python\DLLs\_hashlib.pyd
4079 WARNING: lib not found: libssl-1_1.dll dependency of C:\cheng\Software\Python\DLLs\_ssl.pyd
4095 WARNING: lib not found: VCRUNTIME140.dll dependency of C:\cheng\Software\Python\DLLs\_ssl.pyd
4097 WARNING: lib not found: python37.dll dependency of C:\cheng\Software\Python\DLLs\_ssl.pyd
4106 WARNING: lib not found: libcrypto-1_1.dll dependency of C:\cheng\Software\Python\DLLs\_ssl.pyd
4128 WARNING: lib not found: VCRUNTIME140.dll dependency of C:\cheng\Software\Python\DLLs\unicodedata.pyd
4141 WARNING: lib not found: python37.dll dependency of C:\cheng\Software\Python\DLLs\unicodedata.pyd
4161 WARNING: lib not found: VCRUNTIME140.dll dependency of C:\cheng\Software\Python\DLLs\pyexpat.pyd
4171 WARNING: lib not found: python37.dll dependency of C:\cheng\Software\Python\DLLs\pyexpat.pyd
4174 INFO: Looking for eggs
4174 INFO: Python library not in binary dependencies. Doing additional searching...
4180 INFO: Using Python library
4180 INFO: Found binding redirects:
[]
4194 INFO: Warnings written to C:\cheng\Project\STC_Tool\venv\build\test\warn-test.txt
4252 INFO: Graph cross-reference written to C:\cheng\Project\STC_Tool\venv\build\test\xref-test.html
4261 INFO: checking PYZ
4268 INFO: Building because toc changed
4270 INFO: Building PYZ (ZlibArchive) C:\cheng\Project\STC_Tool\venv\build\test\PYZ-00.pyz
4875 INFO: Building PYZ (ZlibArchive) C:\cheng\Project\STC_Tool\venv\build\test\PYZ-00.pyz completed successfully.
4890 INFO: checking PKG
4891 INFO: Building because toc changed
4893 INFO: Building PKG (CArchive) PKG-00.pkg
Traceback (most recent call last):
File "C:\cheng\Software\Python\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\cheng\Software\Python\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\cheng\Project\STC_Tool\venv\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\__main__.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\building\build_main.py", line 734, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\building\build_main.py", line 681, in build
exec(code, spec_namespace)
File "C:\cheng\Project\STC_Tool\venv\test.spec", line 33, in <module>
console=True )
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\building\api.py", line 436, in __init__
upx_exclude=self.upx_exclude
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\building\api.py", line 199, in __init__
self.__postinit__()
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
self.assemble()
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\building\api.py", line 262, in assemble
dist_nm=inm)
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\building\utils.py", line 220, in checkCache
digest = cacheDigest(fnm, redirects)
File "c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\building\utils.py", line 365, in cacheDigest
with open(fnm, "rb") as f:
FileNotFoundError: [Errno 2] No such file or directory: ''
if I remobve -F option and type pyinstaller test.py directly , the packaing would be successfully
(venv) C:\cheng\Project\STC_Tool\venv>pyinstaller test.py
65 INFO: PyInstaller: 3.6
65 INFO: Python: 3.7.8
66 INFO: Platform: Windows-10-10.0.18362-SP0
68 INFO: wrote C:\cheng\Project\STC_Tool\venv\test.spec
70 INFO: UPX is not available.
70 INFO: Extending PYTHONPATH with paths
['C:\\cheng\\Project\\STC_Tool\\venv', 'C:\\cheng\\Project\\STC_Tool\\venv']
70 INFO: checking Analysis
75 INFO: checking PYZ
98 INFO: checking PKG
98 INFO: Building because toc changed
99 INFO: Building PKG (CArchive) PKG-00.pkg
125 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
128 INFO: Bootloader c:\cheng\project\stc_tool\venv\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
129 INFO: checking EXE
131 INFO: Building because toc changed
132 INFO: Building EXE from EXE-00.toc
134 INFO: Appending archive to EXE C:\cheng\Project\STC_Tool\venv\build\test\test.exe
137 INFO: Building EXE from EXE-00.toc completed successfully.
142 INFO: checking COLLECT
WARNING: The output directory "C:\cheng\Project\STC_Tool\venv\dist\test" and ALL ITS CONTENTS will be REMOVED! Continue? (y/N)y
On your own risk, you can use the option `--noconfirm` to get rid of this question.
2769 INFO: Removing dir C:\cheng\Project\STC_Tool\venv\dist\test
2780 INFO: Building COLLECT COLLECT-00.toc
2830 INFO: Building COLLECT COLLECT-00.toc completed successfully.
but the test.exe flashed and closed after I click , I using screen recording tool capture the flash error
, it shows Error loading Python DLL 'c:\cheng\Project\STC_Tool\venv\dist\test'
the python installed on win10 is python3.7 , and I am using win10 64 bit operating system.
could you please give me some suggestiones .

after unistall pyinstaller and then reinstall pyinstaller again , issue solved.
please considered to update system variable as well.

Related

need help on pyinstaller in pycharm

I'm trying to build an exe file from my pycharm project but it did not succeed. I've tried several solutions from the Internet but they didn't work for me. there was nothing in the dist folder.
the statement I used was "pyinstaller main.py". I also upgraded pyinstaller from 4.2 to 5.0 and it still didn't work.
please help. Thanks
Here is the output from both Pycharm terminal.
Microsoft Windows [Version 10.0.18363.1440]
(c) 2019 Microsoft Corporation. All rights reserved.
(venv) C:\Users\Ghia\PycharmProjects\test>pyinstaller main.py
130 INFO: PyInstaller: 4.2
130 INFO: Python: 3.9.2
130 INFO: Platform: Windows-10-10.0.18362-SP0
130 INFO: wrote C:\Users\Ghia\PycharmProjects\test\main.spec
137 INFO: UPX is not available.
140 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Ghia\\PycharmProjects\\test',
'C:\\Users\\Ghia\\PycharmProjects\\test']
150 INFO: checking Analysis
150 INFO: Building Analysis because Analysis-00.toc is non existent
159 INFO: Initializing module dependency graph...
170 INFO: Caching module graph hooks...
190 WARNING: Several hooks defined for module 'win32ctypes.core'. Please take care they do not conflict.
199 INFO: Analyzing base_library.zip ...
6866 INFO: Processing pre-find module path hook distutils from 'c:\\users\\ghia\\pycharmprojects\\test\\venv\\lib\\site-packages\\PyInstaller\\hooks\\pre
_find_module_path\\hook-distutils.py'.
6870 INFO: distutils: retargeting to non-venv dir 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\\lib'
9638 INFO: Caching module dependency graph...
9848 INFO: running Analysis Analysis-00.toc
9856 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\users\ghia\pycharmprojects\test\venv\scripts\python.exe
9879 INFO: Analyzing C:\Users\Ghia\PycharmProjects\test\main.py
10145 INFO: Processing module hooks...
10146 INFO: Loading module hook 'hook-difflib.py' from 'c:\\users\\ghia\\pycharmprojects\\test\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
10148 INFO: Excluding import of doctest from module difflib
10148 INFO: Loading module hook 'hook-distutils.py' from 'c:\\users\\ghia\\pycharmprojects\\test\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
10150 INFO: Loading module hook 'hook-encodings.py' from 'c:\\users\\ghia\\pycharmprojects\\test\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
10459 INFO: Loading module hook 'hook-heapq.py' from 'c:\\users\\ghia\\pycharmprojects\\test\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
10461 INFO: Excluding import of doctest from module heapq
10462 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'c:\\users\\ghia\\pycharmprojects\\test\\venv\\lib\\site-packages\\PyInstaller\\hooks
'...
10464 INFO: Excluding import of test from module multiprocessing.util
10464 INFO: Excluding import of test.support from module multiprocessing.util
10464 INFO: Loading module hook 'hook-pickle.py' from 'c:\\users\\ghia\\pycharmprojects\\test\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
10466 INFO: Excluding import of argparse from module pickle
10466 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\\users\\ghia\\pycharmprojects\\test\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
10468 INFO: Loading module hook 'hook-xml.py' from 'c:\\users\\ghia\\pycharmprojects\\test\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
10838 INFO: Loading module hook 'hook-_tkinter.py' from 'c:\\users\\ghia\\pycharmprojects\\test\\venv\\lib\\site-packages\\PyInstaller\\hooks'...
10850 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\DL
Ls\_tkinter.pyd
11370 INFO: checking Tree
11489 INFO: checking Tree
11779 INFO: checking Tree
11819 INFO: Looking for ctypes DLLs
11824 INFO: Analyzing run-time hooks ...
11829 INFO: Including run-time hook 'c:\\users\\ghia\\pycharmprojects\\test\\venv\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessi
ng.py'
11834 INFO: Including run-time hook 'c:\\users\\ghia\\pycharmprojects\\test\\venv\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth__tkinter.py'
11843 INFO: Looking for dynamic libraries
11860 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\DL
Ls\_multiprocessing.pyd
11888 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\DL
Ls\unicodedata.pyd
11917 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\DL
Ls\select.pyd
11945 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\DL
Ls\_socket.pyd
11988 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\DL
Ls\_decimal.pyd
12024 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\DL
Ls\_overlapped.pyd
12072 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\DL
Ls\_ssl.pyd
12106 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\DL
Ls\_queue.pyd
12135 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\DL
Ls\pyexpat.pyd
12156 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\DL
Ls\_asyncio.pyd
12179 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\DL
Ls\_hashlib.pyd
12208 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\DL
Ls\_lzma.pyd
12235 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\DL
Ls\_bz2.pyd
12269 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\DL
Ls\_ctypes.pyd
12305 WARNING: lib not found: python39.dll dependency of C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\DL
Ls\_tkinter.pyd
12621 INFO: Looking for eggs
12621 INFO: Python library not in binary dependencies. Doing additional searching...
12623 WARNING: Can not get binary dependencies for file: C:\Users\Ghia\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra
8p0\python.exe
12623 WARNING: Reason: 'The file is empty'
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.752.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Ghia\PycharmProjects\test\venv\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "c:\users\ghia\pycharmprojects\test\venv\lib\site-packages\PyInstaller\__main__.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\users\ghia\pycharmprojects\test\venv\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\ghia\pycharmprojects\test\venv\lib\site-packages\PyInstaller\building\build_main.py", line 725, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\users\ghia\pycharmprojects\test\venv\lib\site-packages\PyInstaller\building\build_main.py", line 672, in build
exec(code, spec_namespace)
File "C:\Users\Ghia\PycharmProjects\test\main.spec", line 6, in <module>
a = Analysis(['main.py'],
File "c:\users\ghia\pycharmprojects\test\venv\lib\site-packages\PyInstaller\building\build_main.py", line 242, in __init__
self.__postinit__()
File "c:\users\ghia\pycharmprojects\test\venv\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
self.assemble()
File "c:\users\ghia\pycharmprojects\test\venv\lib\site-packages\PyInstaller\building\build_main.py", line 476, in assemble
self._check_python_library(self.binaries)
File "c:\users\ghia\pycharmprojects\test\venv\lib\site-packages\PyInstaller\building\build_main.py", line 569, in _check_python_library
python_lib = bindepend.get_python_library_path()
File "c:\users\ghia\pycharmprojects\test\venv\lib\site-packages\PyInstaller\depend\bindepend.py", line 945, in get_python_library_path
raise IOError(msg)
OSError: Python library not found: python39.dll, libpython3.9m.dll, libpython3.9.dll, libpython39.dll, libpython39m.dll
This would mean your Python installation doesn't come with proper library files.
This usually happens by missing development package, or unsuitable build parameters of Python installation.
* On Debian/Ubuntu, you would need to install Python development packages
* apt-get install python3-dev
* apt-get install python-dev
* If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)
upgrade pip and try to install pyinstaller from github repo
python.exe -m pip install --upgrade pip
python.exe -m pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
after that try to build exe file.
pyinstaller "filename"
'pyinstaller' is not recognized as an internal or external command,
operable program or batch file. it gave me this

Pyinstaller not working for package (pyreadstat)

I always have used pyinstaller to create executables files but now when on working on a older project I am facing some issues.
I have figured out that the main problem is while importing pyreadstat package. (pyreadstat is a python package to read spss files.)
import pyreadstat
Post running pyinstaller it first gives error for Module not found pandas. To resolve this I added --hidden-import pandas then it gave another error about Module not found pyreadstat._readstat_writer.
Once I added that as hidden import I got Module not found worker.
I am now not sure why pyinstaller is behaving in this way. Earlier it used to work correctly.
Can someone provider their input here. Below is the cmd log for reference.
D:\Projects\Test>pyinstaller --onefile test.py
62 INFO: PyInstaller: 4.1
62 INFO: Python: 3.9.1
62 INFO: Platform: Windows-10-10.0.19041-SP0
62 INFO: wrote D:\Projects\Test\test.spec
62 INFO: UPX is not available.
69 INFO: Extending PYTHONPATH with paths
['D:\\Projects\\Test', 'D:\\Projects\\Test']
69 INFO: checking Analysis
69 INFO: Building Analysis because Analysis-00.toc is non existent
69 INFO: Initializing module dependency graph...
69 INFO: Caching module graph hooks...
85 INFO: Analyzing base_library.zip ...
1941 INFO: Processing pre-find module path hook distutils from 'c:\\program files\\python39\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
1941 INFO: distutils: retargeting to non-venv dir 'c:\\program files\\python39\\lib'
3458 INFO: Caching module dependency graph...
3552 INFO: running Analysis Analysis-00.toc
3552 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\program files\python39\python.exe
3599 WARNING: lib not found: api-ms-win-core-path-l1-1-0.dll dependency of c:\program files\python39\python39.dll
3615 INFO: Analyzing D:\Projects\Test\test.py
3630 INFO: Processing module hooks...
3630 INFO: Loading module hook 'hook-difflib.py' from 'c:\\program files\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
3630 INFO: Excluding import of doctest from module difflib
3630 INFO: Loading module hook 'hook-distutils.py' from 'c:\\program files\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
3630 INFO: Loading module hook 'hook-distutils.util.py' from 'c:\\program files\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
3630 INFO: Excluding import of lib2to3.refactor from module distutils.util
3630 INFO: Loading module hook 'hook-encodings.py' from 'c:\\program files\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
3703 INFO: Loading module hook 'hook-heapq.py' from 'c:\\program files\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
3703 INFO: Excluding import of doctest from module heapq
3703 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\\program files\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
3828 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'c:\\program files\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
3828 INFO: Excluding import of test.support from module multiprocessing.util
3828 INFO: Excluding import of test from module multiprocessing.util
3844 INFO: Loading module hook 'hook-pickle.py' from 'c:\\program files\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
3844 INFO: Excluding import of argparse from module pickle
3844 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\\program files\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
3844 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\\program files\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
3844 INFO: Loading module hook 'hook-xml.py' from 'c:\\program files\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
3891 INFO: Loading module hook 'hook-_tkinter.py' from 'c:\\program files\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
4006 INFO: checking Tree
4006 INFO: Building Tree because Tree-00.toc is non existent
4021 INFO: Building Tree Tree-00.toc
4085 INFO: checking Tree
4085 INFO: Building Tree because Tree-01.toc is non existent
4085 INFO: Building Tree Tree-01.toc
4180 INFO: checking Tree
4180 INFO: Building Tree because Tree-02.toc is non existent
4180 INFO: Building Tree Tree-02.toc
4196 INFO: Looking for ctypes DLLs
4211 INFO: Analyzing run-time hooks ...
4211 INFO: Including run-time hook 'c:\\program files\\python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
4211 INFO: Looking for dynamic libraries
4446 INFO: Looking for eggs
4446 INFO: Using Python library c:\program files\python39\python39.dll
4446 INFO: Found binding redirects:
[]
4446 INFO: Warnings written to D:\Projects\Test\build\test\warn-test.txt
4477 INFO: Graph cross-reference written to D:\Projects\Test\build\test\xref-test.html
4524 INFO: checking PYZ
4524 INFO: Building PYZ because PYZ-00.toc is non existent
4524 INFO: Building PYZ (ZlibArchive) D:\Projects\Test\build\test\PYZ-00.pyz
4883 INFO: Building PYZ (ZlibArchive) D:\Projects\Test\build\test\PYZ-00.pyz completed successfully.
4899 INFO: checking PKG
4899 INFO: Building PKG because PKG-00.toc is non existent
4899 INFO: Building PKG (CArchive) PKG-00.pkg
6528 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
6528 INFO: Bootloader c:\program files\python39\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
6528 INFO: checking EXE
6528 INFO: Building EXE because EXE-00.toc is non existent
6528 INFO: Building EXE from EXE-00.toc
6528 INFO: Appending archive to EXE D:\Projects\Test\dist\test.exe
6700 INFO: Building EXE from EXE-00.toc completed successfully.
D:\Projects\Test>cd dist
D:\Projects\Test\dist>test.exe
Traceback (most recent call last):
File "test.py", line 1, in <module>
File "c:\program files\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "pyreadstat\__init__.py", line 17, in <module>
File "pyreadstat\pyreadstat.pyx", line 1, in init pyreadstat.pyreadstat
File "pyreadstat\_readstat_parser.pyx", line 28, in init pyreadstat._readstat_parser
ModuleNotFoundError: No module named 'pandas'
[10584] Failed to execute script test

How to use pyinstaller with pipenv / pyenv

I am trying to ship an executable from my python script which lives inside a virtual environment using pipenv which again relies on pyenv for python versioning. For that, I want to us pyinstaller.
What I did:
pipenv install pyinstaller
pyinstaller --onefile my_script.py
Output:
40 INFO: PyInstaller: 3.5
40 INFO: Python: 3.6.9
41 INFO: Platform: Linux-4.15.0-65-generic-x86_64-with-debian-stretch-sid
42 INFO: wrote /home/matthaeus/cybathlon/planvec/qt_video_gui_example.spec
44 INFO: UPX is not available.
45 INFO: Extending PYTHONPATH with paths
['/home/matthaeus/cybathlon/planvec', '/home/matthaeus/cybathlon/planvec']
45 INFO: checking Analysis
45 INFO: Building Analysis because Analysis-00.toc is non existent
45 INFO: Initializing module dependency graph...
46 INFO: Initializing module graph hooks...
47 INFO: Analyzing base_library.zip ...
2786 INFO: running Analysis Analysis-00.toc
2801 INFO: Caching module hooks...
2805 INFO: Analyzing /home/matthaeus/cybathlon/planvec/qt_video_gui_example.py
3284 INFO: Processing pre-find module path hook distutils
3285 INFO: distutils: retargeting to non-venv dir '/home/matthaeus/.pyenv/versions/3.6.9/lib/python3.6/distutils/__init__.py'
3972 INFO: Processing pre-safe import module hook setuptools.extern.six.moves
4336 INFO: Processing pre-find module path hook site
4337 INFO: site: retargeting to fake-dir '/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/fake-modules'
6327 INFO: Loading module hooks...
6328 INFO: Loading module hook "hook-numpy.core.py"...
6458 INFO: Loading module hook "hook-sysconfig.py"...
6464 INFO: Loading module hook "hook-PyQt5.QtCore.py"...
6534 INFO: Loading module hook "hook-scipy.py"...
6535 INFO: Loading module hook "hook-PyQt5.py"...
6549 WARNING: Hidden import "sip" not found!
6549 INFO: Loading module hook "hook-pkg_resources.py"...
6788 INFO: Processing pre-safe import module hook win32com
7015 INFO: Loading module hook "hook-numpy.py"...
7015 INFO: Loading module hook "hook-cv2.py"...
7016 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
7048 INFO: Loading module hook "hook-PyQt5.QtWidgets.py"...
7096 INFO: Loading module hook "hook-pydoc.py"...
7097 INFO: Loading module hook "hook-xml.py"...
7150 INFO: Loading module hook "hook-encodings.py"...
7203 INFO: Loading module hook "hook-setuptools.py"...
7423 WARNING: Hidden import "distutils.command.build_ext" not found!
7680 INFO: Looking for ctypes DLLs
7762 INFO: Analyzing run-time hooks ...
7769 INFO: Including run-time hook 'pyi_rth_pyqt5.py'
7770 INFO: Including run-time hook 'pyi_rth_pkgres.py'
7771 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
7785 INFO: Looking for dynamic libraries
9784 INFO: Looking for eggs
9784 INFO: Python library not in binary dependencies. Doing additional searching...
Traceback (most recent call last):
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/bin/pyinstaller", line 8, in <module>
sys.exit(run())
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 844, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 791, in build
exec(code, spec_namespace)
File "/home/matthaeus/cybathlon/planvec/qt_video_gui_example.spec", line 17, in <module>
noarchive=False)
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 243, in __init__
self.__postinit__()
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/datastruct.py", line 158, in __postinit__
self.assemble()
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 575, in assemble
self._check_python_library(self.binaries)
File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 681, in _check_python_library
raise IOError(msg)
OSError: Python library not found: libpython3.6mu.so.1.0, libpython3.6m.so, libpython3.6m.so.1.0, libpython3.6.so.1.0
This would mean your Python installation doesn't come with proper library files.
This usually happens by missing development package, or unsuitable build parameters of Python installation.
* On Debian/Ubuntu, you would need to install Python development packages
* apt-get install python3-dev
* apt-get install python-dev
* If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)
I tried the recommended python3-dev and python-dev installations without luck.
Now, I hope someone can enlighten me what is going on here!
Cheers,
Matt
You need to build with CPython shared-library enabled.
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.6.9
eval "$(pyenv init -)"
Reference: https://github.com/pyenv/pyenv/wiki

PyInstaller stops working when I import something from PySide

When I build a simple hello world application with PyInstaller, it works as expected. But as soon as I import something from PySide it stops working. Here is the main.py:
from PySide.QtGui import QApplication
print "Hello World"
The build process goes smoothly, but the resulting binary doesn't work:
(pyside) C:\Test\pyinstaller>main\dist\main\main.exe
Traceback (most recent call last):
File "<string>", line 5, in <module>
File "C:\Test\pyinstaller\PyInstaller\loader\iu.py", line 386, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\Test\pyinstaller\PyInstaller\loader\iu.py", line 480, in doimport
exec co in mod.__dict__
File "C:\Test\pyinstaller\main\build\pyi.win32\main\out00-PYZ.pyz\PySide", lin
e 55, in <module>
File "C:\Test\pyinstaller\main\build\pyi.win32\main\out00-PYZ.pyz\PySide", lin
e 11, in _setupQtDirectories
File "C:\Test\pyinstaller\main\build\pyi.win32\main\out00-PYZ.pyz\PySide._util
s", line 87, in get_pyside_dir
File "C:\Test\pyinstaller\main\build\pyi.win32\main\out00-PYZ.pyz\PySide._util
s", line 83, in _get_win32_case_sensitive_name
File "C:\Test\pyinstaller\main\build\pyi.win32\main\out00-PYZ.pyz\PySide._util
s", line 58, in _get_win32_short_name
WindowsError: [Error 123] The filename, directory name, or volume label syntax i
s incorrect.
Notice that this happens even though I'm just importing a PySide module, not actually using it. What should I do?
I am using PyInstaller 2.0 to package an app with PySide 1.2 on 64-bit windows 7. My Python installation is 32-bit:
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
>pip freeze
pyside==1.2.0
pywin32==218
And here is the build message:
(pyside) C:\Test\pyinstaller>python pyinstaller.py ..\main.py
90 INFO: wrote C:\Test\pyinstaller\main\main.spec
113 INFO: Testing for ability to set icons, version resources...
162 INFO: ... resource update available
204 INFO: UPX is available.
1237 INFO: checking Analysis
1237 INFO: building Analysis because out00-Analysis.toc non existent
1238 INFO: running Analysis out00-Analysis.toc
1240 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
1313 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21
022.8_none ...
1314 INFO: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc
8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest
1316 INFO: Searching for file msvcr90.dll
1317 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_
9.0.21022.8_none_bcb86ed6ac711f91\msvcr90.dll
1317 INFO: Searching for file msvcp90.dll
1319 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_
9.0.21022.8_none_bcb86ed6ac711f91\msvcp90.dll
1319 INFO: Searching for file msvcm90.dll
1319 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_
9.0.21022.8_none_bcb86ed6ac711f91\msvcm90.dll
1447 INFO: Analyzing C:\Test\pyinstaller\support\_pyi_bootstrap.py
2601 INFO: Analyzing C:\Test\pyinstaller\PyInstaller\loader\archive.py
2687 INFO: Analyzing C:\Test\pyinstaller\PyInstaller\loader\carchive.py
2776 INFO: Analyzing C:\Test\pyinstaller\PyInstaller\loader\iu.py
2800 INFO: Analyzing ..\main.py
2893 INFO: Hidden import 'encodings' has been found otherwise
2894 INFO: Looking for run-time hooks
2895 INFO: Analyzing rthook C:\Test\pyinstaller\support/rthooks/pyi_rth_encoding
s.py
7438 INFO: Warnings written to C:\Test\pyinstaller\main\build\pyi.win32\main\war
nmain.txt
7444 INFO: checking PYZ
7445 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
7445 INFO: building PYZ out00-PYZ.toc
8059 INFO: checking PKG
8060 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
8061 INFO: building PKG out00-PKG.pkg
8072 INFO: checking EXE
8073 INFO: rebuilding out00-EXE.toc because main.exe missing
8073 INFO: building EXE from out00-EXE.toc
8075 INFO: Appending archive to EXE C:\Test\pyinstaller\main\build\pyi.win32\mai
n\main.exe
8151 INFO: checking COLLECT
8151 INFO: building COLLECT out00-COLLECT.toc
EDIT: This happens even if I call from PySide import QtGui as it suggests in this answer.
Encountering same question, solved by using PyInstaller 1.5.

pyInstaller executable missing module "_struct" on Ubuntu 12.04 Precise

I would like to package my python project into a UNIX executable. For this I've tried py2exe, cxfreeze and pyInstaller, but nothing worked. Hopefully you can help me with pyinstaller. So here it goes:
I've downloaded the zipfile of pyinstaller-2.0 from http://www.pyinstaller.org/ and unzipped it.
In the folder, I run python pyinstaller.py ../helloworld.py (output listed at the end).
Then I try to execute the file: ./helloworld/dist/helloworld/helloworld
which gives me the output:
mod is NULL - structTraceback (most recent call last):
File "/usr/lib/python2.7/struct.py", line 1, in <module>
from _struct import *
ImportError: No module named _struct
mod is NULL - archiveTraceback (most recent call last):
File "/home/jelle/Downloads/pyinstaller-1.5.1/archive.py", line 42, in <module>
import struct
ImportError: No module named struct
Traceback (most recent call last):
File "<string>", line 25, in <module>
ImportError: No module named archive
I'm using Ubuntu 12.04 with Python 2.7.3. My PYTHONPATH include /usr/lib/python2.7. It looks as if the problem is a missing module _struct, but I have no idea where to find it. I've tried pyinstaller 1.5.1 and the development version, neither work here.
Please help!
The output of python pyinstaller.py ../helloworld.py:
7 INFO: wrote /home/jelle/Downloads/pyinstaller-2.0/helloworld/helloworld.spec
27 INFO: UPX is not available.
583 INFO: checking Analysis
583 INFO: building Analysis because out00-Analysis.toc non existent
583 INFO: running Analysis out00-Analysis.toc
702 INFO: Analyzing /home/jelle/Downloads/pyinstaller-2.0/support/_pyi_bootstrap.py
1570 INFO: Analyzing /home/jelle/Downloads/pyinstaller-2.0/PyInstaller/loader/archive.py
1637 INFO: Analyzing /home/jelle/Downloads/pyinstaller-2.0/PyInstaller/loader/carchive.py
1701 INFO: Analyzing /home/jelle/Downloads/pyinstaller-2.0/PyInstaller/loader/iu.py
1720 INFO: Analyzing ../helloworld.py
1721 INFO: Hidden import 'encodings' has been found otherwise
1721 INFO: Looking for run-time hooks
1721 INFO: Analyzing rthook /home/jelle/Downloads/pyinstaller-2.0/support/rthooks/pyi_rth_encodings.py
2197 INFO: Looking for Python library libpython2.7.so
objdump: section '.dynamic' mentioned in a -j option, but not found in any input file
2308 INFO: Warnings written to /home/jelle/Downloads/pyinstaller-2.0/helloworld/build/pyi.linux2/helloworld/warnhelloworld.txt
2311 INFO: checking PYZ
2311 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
2312 INFO: building PYZ out00-PYZ.toc
2706 INFO: checking PKG
2706 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
2706 INFO: building PKG out00-PKG.pkg
2711 INFO: checking EXE
2712 INFO: rebuilding out00-EXE.toc because helloworld missing
2712 INFO: building EXE from out00-EXE.toc
2772 INFO: Appending archive to EXE /home/jelle/Downloads/pyinstaller-2.0/helloworld/build/pyi.linux2/helloworld/helloworld
2773 INFO: checking COLLECT
2773 INFO: building COLLECT out00-COLLECT.toc
BTW: my helloworld.py simply contains the statement print "hello world". I tried putting #!/usr/bin/python2.7 at the top.
Check the value of the system variable LD_LIBRARY_PATH
echo $LD_LIBRARY_PATH
It might point to the wrong python library libpython2.7.so.
In my case, I could fix this by resetting it:
export LD_LIBRARY_PATH=

Categories