Pyinstaller Tkinter hiddenimports = [sysconfig._get_sysconfigdata_name()] ERROR - python

When I try to convert my .py file into an app using pyinstaller, I get the following output on terminal
Rishabhs-MacBook-Pro:desktop rishabhtatia$ pyinstaller --clean --hidden-
import tkinter test.py
697 INFO: PyInstaller: 3.3.1
697 INFO: Python: 3.6.4
709 INFO: Platform: Darwin-17.4.0-x86_64-i386-64bit
711 INFO: wrote /Users/rishabhtatia/Desktop/test.spec
714 INFO: UPX is not available.
716 INFO: Removing temporary files and cleaning cache in /Users/rishabhtatia/Library/Application Support/pyinstaller
Traceback (most recent call last):
File "/Users/rishabhtatia/anaconda3/bin/pyinstaller", line 11, in <module>
sys.exit(run())
File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/__main__.py", line 94, in run
run_build(pyi_config, spec_file, **vars(args))
File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/__main__.py", line 46, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 791, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 737, in build
exec(text, spec_namespace)
File "<string>", line 16, in <module>
File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 162, in __init__
raise ValueError("script '%s' not found" % script)
ValueError: script '/Users/rishabhtatia/Desktop/test.py' not found
Rishabhs-MacBook-Pro:desktop rishabhtatia$ pyinstaller --clean --hidden-import tkinter typeMachine.py
314 INFO: PyInstaller: 3.3.1
314 INFO: Python: 3.6.4
321 INFO: Platform: Darwin-17.4.0-x86_64-i386-64bit
323 INFO: wrote /Users/rishabhtatia/Desktop/typeMachine.spec
326 INFO: UPX is not available.
327 INFO: Removing temporary files and cleaning cache in /Users/rishabhtatia/Library/Application Support/pyinstaller
328 INFO: Extending PYTHONPATH with paths
['/Users/rishabhtatia/Desktop', '/Users/rishabhtatia/Desktop']
328 INFO: checking Analysis
328 INFO: Building Analysis because out00-Analysis.toc is non existent
328 INFO: Initializing module dependency graph...
332 INFO: Initializing module graph hooks...
334 INFO: Analyzing base_library.zip ...
4406 INFO: Analyzing hidden import 'tkinter'
4576 INFO: running Analysis out00-Analysis.toc
4586 INFO: Caching module hooks...
4590 INFO: Analyzing /Users/rishabhtatia/Desktop/typeMachine.py
4827 INFO: Processing pre-safe import module hook six.moves
5525 INFO: Processing pre-find module path hook distutils
10217 INFO: Processing pre-find module path hook site
10218 INFO: site: retargeting to fake-dir '/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/fake-modules'
16738 INFO: Loading module hooks...
16738 INFO: Loading module hook "hook-pkg_resources.py"...
17122 INFO: Processing pre-safe import module hook win32com
17433 INFO: Loading module hook "hook-PyQt5.py"...
17628 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
17630 INFO: Loading module hook "hook-lib2to3.py"...
17633 INFO: Loading module hook "hook-_tkinter.py"...
17877 INFO: checking Tree
17877 INFO: Building Tree because out00-Tree.toc is non existent
17877 INFO: Building Tree out00-Tree.toc
17888 INFO: checking Tree
17888 INFO: Building Tree because out01-Tree.toc is non existent
17889 INFO: Building Tree out01-Tree.toc
17895 INFO: Loading module hook "hook-encodings.py"...
17973 INFO: Loading module hook "hook-PIL.py"...
17979 INFO: Excluding import 'PyQt4'
17981 INFO: Removing import of PyQt4 from module PIL.ImageQt
17981 INFO: Excluding import 'PySide'
17983 INFO: Removing import of PySide from module PIL.ImageQt
17983 INFO: Excluding import 'tkinter'
17985 INFO: Import to be excluded not found: 'FixTk'
17985 INFO: Excluding import 'PyQt5'
17987 INFO: Removing import of PyQt5.QtCore from module PIL.ImageQt
17987 INFO: Removing import of PyQt5.QtGui from module PIL.ImageQt
17987 INFO: Loading module hook "hook-setuptools.py"...
18020 INFO: Loading module hook "hook-pycparser.py"...
18279 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
18847 INFO: Loading module hook "hook-PIL.Image.py"...
19267 INFO: Loading module hook "hook-PyQt5.Qt.py"...
19269 INFO: Loading module hook "hook-pytest.py"...
20348 INFO: Loading module hook "hook-PyQt5.QtWidgets.py"...
20349 INFO: Loading module hook "hook-sysconfig.py"...
Traceback (most recent call last):
File "/Users/rishabhtatia/anaconda3/bin/pyinstaller", line 11, in <module>
sys.exit(run())
File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/__main__.py", line 94, in run
run_build(pyi_config, spec_file, **vars(args))
File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/__main__.py", line 46, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 791, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 737, in build
exec(text, spec_namespace)
File "<string>", line 16, in <module>
File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 213, in __init__
self.__postinit__()
File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/datastruct.py", line 161, in __postinit__
self.assemble()
File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 472, in assemble
module_hook.post_graph()
File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/imphook.py", line 410, in post_graph
self._load_hook_module()
File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/building/imphook.py", line 377, in _load_hook_module
self.hook_module_name, self.hook_filename)
File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/compat.py", line 744, in importlib_load_source
return mod_loader.load_module()
File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 823, in load_module
File "<frozen importlib._bootstrap_external>", line 682, in load_module
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
File "<frozen importlib._bootstrap>", line 684, in _load
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/rishabhtatia/anaconda3/lib/python3.6/site-packages/PyInstaller/hooks/hook-sysconfig.py", line 42, in <module>
hiddenimports = [sysconfig._get_sysconfigdata_name()]
TypeError: _get_sysconfigdata_name() missing 1 required positional argument: 'check_exists'
I've tried to use various different commands with pyinstaller and have tried using py2app with no success.
I'm currently using
python version: 3.6.4
anaconda version: 1.6.9
macOS HighSierra
Any help on how I can successfully convert this python file into an app will be appreciated! Thank you!

I came across the same problem. Upon further investigation, it seems to be the problem with Anaconda introducing breaking changes.
Please get in touch with the anaconda people then. We can not support their distribution any longer if they add incompatible changes.
I had the same issue before, changing the conda environment's python to 3.5.1 removed that error.
I had the same error (with anaconda as well), but only with python version 3.6.4. If I downgrade to 3.6.3, the error disappears.
If you experience this issue, update your conda installation. If this does not help, get in touch with the anaconda people. We can not support their distribution any longer if they add incompatible changes.
See https://github.com/pyinstaller/pyinstaller/issues/3192 for full discussion.

Related

miniaudio (and other modules) - can't create exe

i have just one line of code, and i am trying to generate the exe with pyinstaller command.
import miniaudio
command = pyinstaller <filename>.py
output:
116 INFO: PyInstaller: 4.2
116 INFO: Python: 3.9.2
117 INFO: Platform: Windows-10-10.0.19041-SP0
118 INFO: wrote C:\Users\Χρήστος\Desktop\radio\peradio2.spec
121 INFO: UPX is not available.
122 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Χρήστος\\Desktop\\radio', 'C:\\Users\\Χρήστος\\Desktop\\radio']
135 INFO: checking Analysis
138 INFO: Building because C:\Users\Χρήστος\Desktop\radio\peradio2.py changed
138 INFO: Initializing module dependency graph...
141 INFO: Caching module graph hooks...
148 WARNING: Several hooks defined for module 'win32ctypes.core'. Please take care they do not conflict.
152 INFO: Analyzing base_library.zip ...
2350 INFO: Processing pre-find module path hook distutils from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
2351 INFO: distutils: retargeting to non-venv dir 'c:\\python\\lib'
5208 INFO: Caching module dependency graph...
5297 INFO: running Analysis Analysis-00.toc
5314 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\python\python.exe
5389 WARNING: lib not found: api-ms-win-core-path-l1-1-0.dll dependency of c:\python\python39.dll
5564 INFO: Analyzing C:\Users\Χρήστος\Desktop\radio\peradio2.py
5566 INFO: Processing module hooks...
5567 INFO: Loading module hook 'hook-difflib.py' from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks'...
5569 INFO: Excluding import of doctest from module difflib
5569 INFO: Loading module hook 'hook-distutils.py' from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks'...
5570 INFO: Loading module hook 'hook-distutils.util.py' from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks'...
5572 INFO: Excluding import of lib2to3.refactor from module distutils.util
5572 INFO: Loading module hook 'hook-encodings.py' from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks'...
5642 INFO: Loading module hook 'hook-heapq.py' from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks'...
5643 INFO: Excluding import of doctest from module heapq
5644 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks'...
5697 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks'...
5699 INFO: Excluding import of test from module multiprocessing.util
5699 INFO: Excluding import of test.support from module multiprocessing.util
5700 INFO: Loading module hook 'hook-pickle.py' from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks'...
5701 INFO: Excluding import of argparse from module pickle
5701 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks'...
5702 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks'...
5703 INFO: Loading module hook 'hook-xml.py' from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks'...
5760 INFO: Loading module hook 'hook-_tkinter.py' from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks'...
5896 INFO: checking Tree
5959 INFO: checking Tree
6148 INFO: checking Tree
6165 INFO: Looking for ctypes DLLs
6188 INFO: Analyzing run-time hooks ...
6191 INFO: Including run-time hook 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
6196 INFO: Looking for dynamic libraries
6320 INFO: Looking for eggs
6321 INFO: Using Python library c:\python\python39.dll
6321 INFO: Found binding redirects:
[]
6325 INFO: Warnings written to C:\Users\Χρήστος\Desktop\radio\build\peradio2\warn-peradio2.txt
6359 INFO: Graph cross-reference written to C:\Users\Χρήστος\Desktop\radio\build\peradio2\xref-peradio2.html
6366 INFO: checking PYZ
6375 INFO: Building because toc changed
6375 INFO: Building PYZ (ZlibArchive) C:\Users\Χρήστος\Desktop\radio\build\peradio2\PYZ-00.pyz
6905 INFO: Building PYZ (ZlibArchive) C:\Users\Χρήστος\Desktop\radio\build\peradio2\PYZ-00.pyz completed successfully.
6912 INFO: checking PKG
6920 INFO: Building because toc changed
6920 INFO: Building PKG (CArchive) PKG-00.pkg
6940 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
6941 INFO: Bootloader c:\python\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
6942 INFO: checking EXE
6951 INFO: Rebuilding EXE-00.toc because peradio2.exe missing
6952 INFO: Building EXE from EXE-00.toc
7007 INFO: Copying icons from ['c:\\python\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico']
7071 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
7071 INFO: Writing RT_ICON 1 resource with 3752 bytes
7072 INFO: Writing RT_ICON 2 resource with 2216 bytes
7073 INFO: Writing RT_ICON 3 resource with 1384 bytes
7073 INFO: Writing RT_ICON 4 resource with 37019 bytes
7073 INFO: Writing RT_ICON 5 resource with 9640 bytes
7074 INFO: Writing RT_ICON 6 resource with 4264 bytes
7074 INFO: Writing RT_ICON 7 resource with 1128 bytes
7103 INFO: Appending archive to EXE C:\Users\Χρήστος\Desktop\radio\build\peradio2\peradio2.exe
7261 INFO: Building EXE from EXE-00.toc completed successfully.
7264 INFO: checking COLLECT
7264 INFO: Building COLLECT because COLLECT-00.toc is non existent
7265 INFO: Building COLLECT COLLECT-00.toc
7570 INFO: Building COLLECT COLLECT-00.toc completed successfully.
C:\Users\Χρήστος\Desktop\radio>pyinstaller --hidden-import=miniaudio peradio2.py
118 INFO: PyInstaller: 4.2
119 INFO: Python: 3.9.2
120 INFO: Platform: Windows-10-10.0.19041-SP0
121 INFO: wrote C:\Users\Χρήστος\Desktop\radio\peradio2.spec
123 INFO: UPX is not available.
130 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Χρήστος\\Desktop\\radio', 'C:\\Users\\Χρήστος\\Desktop\\radio']
144 INFO: checking Analysis
154 INFO: Building because hiddenimports changed
155 INFO: Initializing module dependency graph...
158 INFO: Caching module graph hooks...
165 WARNING: Several hooks defined for module 'win32ctypes.core'. Please take care they do not conflict.
169 INFO: Analyzing base_library.zip ...
2849 INFO: Processing pre-find module path hook distutils from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
2849 INFO: distutils: retargeting to non-venv dir 'c:\\python\\lib'
4998 INFO: Caching module dependency graph...
5090 INFO: running Analysis Analysis-00.toc
5103 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\python\python.exe
5161 WARNING: lib not found: api-ms-win-core-path-l1-1-0.dll dependency of c:\python\python39.dll
5373 INFO: Analyzing C:\Users\Χρήστος\Desktop\radio\peradio2.py
6202 INFO: Processing pre-find module path hook site from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
6203 INFO: site: retargeting to fake-dir 'c:\\python\\lib\\site-packages\\PyInstaller\\fake-modules'
8558 INFO: Processing pre-safe import module hook six.moves from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-six.moves.py'.
11175 INFO: Processing module hooks...
11175 INFO: Loading module hook 'hook-pycparser.py' from 'c:\\python\\lib\\site-packages\\pyinstaller_hooks_contrib-2021.1-py3.9.egg\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
11177 INFO: Loading module hook 'hook-pytest.py' from 'c:\\python\\lib\\site-packages\\pyinstaller_hooks_contrib-2021.1-py3.9.egg\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
Traceback (most recent call last):
File "c:\python\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\python\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Python\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "c:\python\lib\site-packages\PyInstaller\__main__.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\python\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\python\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:\python\lib\site-packages\PyInstaller\building\build_main.py", line 672, in build
exec(code, spec_namespace)
File "C:\Users\Χρήστος\Desktop\radio\peradio2.spec", line 6, in <module>
a = Analysis(['peradio2.py'],
File "c:\python\lib\site-packages\PyInstaller\building\build_main.py", line 242, in __init__
self.__postinit__()
File "c:\python\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
self.assemble()
File "c:\python\lib\site-packages\PyInstaller\building\build_main.py", line 420, in assemble
self.graph.process_post_graph_hooks()
File "c:\python\lib\site-packages\PyInstaller\depend\analysis.py", line 367, in process_post_graph_hooks
module_hook.post_graph()
File "c:\python\lib\site-packages\PyInstaller\depend\imphook.py", line 447, in post_graph
self._load_hook_module()
File "c:\python\lib\site-packages\PyInstaller\depend\imphook.py", line 408, in _load_hook_module
self._hook_module = importlib_load_source(
File "c:\python\lib\site-packages\PyInstaller\compat.py", line 598, in importlib_load_source
return mod_loader.load_module()
File "<frozen importlib._bootstrap_external>", line 469, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 969, in load_module
File "<frozen importlib._bootstrap_external>", line 794, in load_module
File "<frozen importlib._bootstrap>", line 274, in _load_module_shim
File "<frozen importlib._bootstrap>", line 711, in _load
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "c:\python\lib\site-packages\pyinstaller_hooks_contrib-2021.1-py3.9.egg\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-pytest.py", line 18, in <module>
import pytest
File "c:\python\lib\site-packages\pytest.py", line 8, in <module>
from _pytest.assertion import register_assert_rewrite
File "c:\python\lib\site-packages\_pytest\assertion\__init__.py", line 13, in <module>
from _pytest.assertion import rewrite
File "c:\python\lib\site-packages\_pytest\assertion\rewrite.py", line 24, in <module>
from _pytest.assertion import util
File "c:\python\lib\site-packages\_pytest\assertion\util.py", line 11, in <module>
import _pytest._code
File "c:\python\lib\site-packages\_pytest\_code\__init__.py", line 7, in <module>
from .code import Code # noqa
File "c:\python\lib\site-packages\_pytest\_code\code.py", line 15, in <module>
import pluggy
File "c:\python\lib\site-packages\pluggy\__init__.py", line 16, in <module>
from .manager import PluginManager, PluginValidationError
File "c:\python\lib\site-packages\pluggy\manager.py", line 6, in <module>
import importlib_metadata
File "c:\python\lib\site-packages\importlib_metadata\__init__.py", line 471, in <module>
__version__ = version(__name__)
File "c:\python\lib\site-packages\importlib_metadata\__init__.py", line 438, in version
return distribution(package).version
File "c:\python\lib\site-packages\importlib_metadata\__init__.py", line 411, in distribution
return Distribution.from_name(package)
File "c:\python\lib\site-packages\importlib_metadata\__init__.py", line 179, in from_name
dists = resolver(name)
File "<frozen importlib._bootstrap_external>", line 1389, in find_distributions
File "c:\python\lib\importlib\metadata.py", line 487, in find_distributions
found = cls._search_paths(context.name, context.path)
AttributeError: 'str' object has no attribute 'name'
C:\Users\Χρήστος\Desktop\radio>pyinstaller peradio2.py
118 INFO: PyInstaller: 4.2
118 INFO: Python: 3.9.2
119 INFO: Platform: Windows-10-10.0.19041-SP0
120 INFO: wrote C:\Users\Χρήστος\Desktop\radio\peradio2.spec
123 INFO: UPX is not available.
125 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Χρήστος\\Desktop\\radio', 'C:\\Users\\Χρήστος\\Desktop\\radio']
138 INFO: checking Analysis
141 INFO: Building because C:\Users\Χρήστος\Desktop\radio\peradio2.py changed
141 INFO: Initializing module dependency graph...
144 INFO: Caching module graph hooks...
151 WARNING: Several hooks defined for module 'win32ctypes.core'. Please take care they do not conflict.
155 INFO: Analyzing base_library.zip ...
2197 INFO: Processing pre-find module path hook distutils from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
2197 INFO: distutils: retargeting to non-venv dir 'c:\\python\\lib'
5129 INFO: Caching module dependency graph...
5250 INFO: running Analysis Analysis-00.toc
5267 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\python\python.exe
5342 WARNING: lib not found: api-ms-win-core-path-l1-1-0.dll dependency of c:\python\python39.dll
5538 INFO: Analyzing C:\Users\Χρήστος\Desktop\radio\peradio2.py
6348 INFO: Processing pre-find module path hook site from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
6351 INFO: site: retargeting to fake-dir 'c:\\python\\lib\\site-packages\\PyInstaller\\fake-modules'
8738 INFO: Processing pre-safe import module hook six.moves from 'c:\\python\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-six.moves.py'.
11357 INFO: Processing module hooks...
11357 INFO: Loading module hook 'hook-pycparser.py' from 'c:\\python\\lib\\site-packages\\pyinstaller_hooks_contrib-2021.1-py3.9.egg\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
11359 INFO: Loading module hook 'hook-pytest.py' from 'c:\\python\\lib\\site-packages\\pyinstaller_hooks_contrib-2021.1-py3.9.egg\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
Traceback (most recent call last):
File "c:\python\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\python\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Python\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "c:\python\lib\site-packages\PyInstaller\__main__.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\python\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\python\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:\python\lib\site-packages\PyInstaller\building\build_main.py", line 672, in build
exec(code, spec_namespace)
File "C:\Users\Χρήστος\Desktop\radio\peradio2.spec", line 6, in <module>
a = Analysis(['peradio2.py'],
File "c:\python\lib\site-packages\PyInstaller\building\build_main.py", line 242, in __init__
self.__postinit__()
File "c:\python\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
self.assemble()
File "c:\python\lib\site-packages\PyInstaller\building\build_main.py", line 420, in assemble
self.graph.process_post_graph_hooks()
File "c:\python\lib\site-packages\PyInstaller\depend\analysis.py", line 367, in process_post_graph_hooks
module_hook.post_graph()
File "c:\python\lib\site-packages\PyInstaller\depend\imphook.py", line 447, in post_graph
self._load_hook_module()
File "c:\python\lib\site-packages\PyInstaller\depend\imphook.py", line 408, in _load_hook_module
self._hook_module = importlib_load_source(
File "c:\python\lib\site-packages\PyInstaller\compat.py", line 598, in importlib_load_source
return mod_loader.load_module()
File "<frozen importlib._bootstrap_external>", line 469, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 969, in load_module
File "<frozen importlib._bootstrap_external>", line 794, in load_module
File "<frozen importlib._bootstrap>", line 274, in _load_module_shim
File "<frozen importlib._bootstrap>", line 711, in _load
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "c:\python\lib\site-packages\pyinstaller_hooks_contrib-2021.1-py3.9.egg\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-pytest.py", line 18, in <module>
import pytest
File "c:\python\lib\site-packages\pytest.py", line 8, in <module>
from _pytest.assertion import register_assert_rewrite
File "c:\python\lib\site-packages\_pytest\assertion\__init__.py", line 13, in <module>
from _pytest.assertion import rewrite
File "c:\python\lib\site-packages\_pytest\assertion\rewrite.py", line 24, in <module>
from _pytest.assertion import util
File "c:\python\lib\site-packages\_pytest\assertion\util.py", line 11, in <module>
import _pytest._code
File "c:\python\lib\site-packages\_pytest\_code\__init__.py", line 7, in <module>
from .code import Code # noqa
File "c:\python\lib\site-packages\_pytest\_code\code.py", line 15, in <module>
import pluggy
File "c:\python\lib\site-packages\pluggy\__init__.py", line 16, in <module>
from .manager import PluginManager, PluginValidationError
File "c:\python\lib\site-packages\pluggy\manager.py", line 6, in <module>
import importlib_metadata
File "c:\python\lib\site-packages\importlib_metadata\__init__.py", line 471, in <module>
__version__ = version(__name__)
File "c:\python\lib\site-packages\importlib_metadata\__init__.py", line 438, in version
return distribution(package).version
File "c:\python\lib\site-packages\importlib_metadata\__init__.py", line 411, in distribution
return Distribution.from_name(package)
File "c:\python\lib\site-packages\importlib_metadata\__init__.py", line 179, in from_name
dists = resolver(name)
File "<frozen importlib._bootstrap_external>", line 1389, in find_distributions
File "c:\python\lib\importlib\metadata.py", line 487, in find_distributions
found = cls._search_paths(context.name, context.path)
AttributeError: 'str' object has no attribute 'name'
I tried to uninstall and then reinstall pyinstall six enum34 and setuptools but the error doesn't gone.
It's the first time i use miniaudio module.
Can anyone help me about?
Thanks in advance,
Chris Pappas
**Edit: ** I found that is not the only module about that problem.
pip uninstall importlib-metadata
pip install importlib-metadata
Fix the errors!!!
I had a very old version of this module 0.x . now 3.x

PyInstaller and OpenGL Error. ImportError: cannot import name 'opengl_arrays_modules' from 'PyInstaller.utils.hooks'

I installed the latest version of PyInstaller using this command: pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
I try to bundle the simplest code using this command: pyinstaller --onefile --noupx main.py
main.py
from OpenGL import GL
print("Hello, OpenGL")
I got this error: ImportError: cannot import name 'opengl_arrays_modules' from 'PyInstaller.utils.hooks'
Full log:
PS E:\_Projects\Python\SDL2\pyopengl_demo> pyinstaller --onefile main.py
124 INFO: PyInstaller: 4.0.dev0
124 INFO: Python: 3.7.8
138 INFO: Platform: Windows-10-10.0.18362-SP0
140 INFO: wrote E:\_Projects\Python\SDL2\pyopengl_demo\main.spec
283 INFO: UPX is available.
287 INFO: Extending PYTHONPATH with paths
['E:\\_Projects\\Python\\SDL2\\pyopengl_demo',
'E:\\_Projects\\Python\\SDL2\\pyopengl_demo']
338 INFO: checking Analysis
339 INFO: Building Analysis because Analysis-00.toc is non existent
340 INFO: Initializing module dependency graph...
351 INFO: Caching module graph hooks...
401 INFO: Analyzing base_library.zip ...
5023 INFO: Processing pre-find module path hook distutils from 'C:\\Users\\8Observer8\\AppData\\Roaming\\Python\\Python37\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
5039 INFO: distutils: retargeting to non-venv dir 'c:\\program files (x86)\\python37-32\\lib'
7945 INFO: Caching module dependency graph...
8243 INFO: running Analysis Analysis-00.toc
8248 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\program files (x86)\python37-32\python.exe
8445 INFO: Analyzing E:\_Projects\Python\SDL2\pyopengl_demo\main.py
16293 INFO: Processing pre-find module path hook site from 'C:\\Users\\8Observer8\\AppData\\Roaming\\Python\\Python37\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
16308 INFO: site: retargeting to fake-dir 'C:\\Users\\8Observer8\\AppData\\Roaming\\Python\\Python37\\site-packages\\PyInstaller\\fake-modules'
18941 INFO: Processing pre-safe import module hook setuptools.extern.six.moves from 'C:\\Users\\8Observer8\\AppData\\Roaming\\Python\\Python37\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-setuptools.extern.six.moves.py'.
24985 INFO: Processing module hooks...
24988 INFO: Loading module hook 'hook-OpenGL.py' from 'C:\\Users\\8Observer8\\AppData\\Roaming\\Python\\Python37\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
Traceback (most recent call last):
File "c:\program files (x86)\python37-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\program files (x86)\python37-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\__main__.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\build_main.py", line 716, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\build_main.py", line 663, in build
exec(code, spec_namespace)
File "E:\_Projects\Python\SDL2\pyopengl_demo\main.spec", line 17, in <module>
noarchive=False)
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\build_main.py", line 241, in __init__
self.__postinit__()
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
self.assemble()
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\build_main.py", line 418, in assemble
self.graph.process_post_graph_hooks()
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\depend\analysis.py", line 365, in process_post_graph_hooks
module_hook.post_graph()
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\depend\imphook.py", line 440, in post_graph
self._load_hook_module()
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\depend\imphook.py", line 407, in _load_hook_module
self.hook_module_name, self.hook_filename)
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\compat.py", line 588, in importlib_load_source
return mod_loader.load_module()
File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 907, in load_module
File "<frozen importlib._bootstrap_external>", line 732, in load_module
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
File "<frozen importlib._bootstrap>", line 696, in _load
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-OpenGL.py", line 24, in <module>
from PyInstaller.utils.hooks import opengl_arrays_modules
ImportError: cannot import name 'opengl_arrays_modules' from 'PyInstaller.utils.hooks' (C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\PyInstaller\utils\hooks\__init__.py)
Using python 3.8.5:
I tried to upgrade the hooks :
pip install -U pyinstaller-hooks-contrib
to upgrade the hooks, it replies with
Requirement already up-to-date: pyinstaller-hooks-contrib in c:\python38\lib\site-packages (2020.7)
I removed the pip version :
pip uninstall pyinstaller-hooks-contrib
So, I had to update with the repository files:
git clone https://github.com/pyinstaller/pyinstaller-hooks-contrib.git
cd pyinstaller-hooks-contrib
python setup.py install
I have now 2020.8 version setted up and the inital problem is solved
Pyinstaller developpers have recently made changes in the hooks. The one for OpenGL has been moved to https://github.com/pyinstaller/pyinstaller-hooks-contrib . I believe you still have the old hook from a previous installation of pyinstaller. This one will not work since they also made changes in the code. You should delete the OpeenGL hook (C:\Users\8Observer8\AppData\Roaming\Python\Python37\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-OpenGL.py) or remove pyinstaller and install it again. Then get the contrib form github and point to it with --additional-hooks-dir
It doesn't work with wxPython.
I did all of this.
I saw that
It works with OpenGL from PySDL2 and PySide2

PyInstaller is not creating an .exe file

I'm trying to create an executable file using PyInstaller with my script. For reference, I am using Windows 10 with Python 3.8.0 and PyInstaller version 3.5.
My script is called hello_world.py and it is saved in it's own folder.
print("Hello World!")
In command prompt, I navigate to the folder that hello_world.py is in and run:
pyinstaller hello_world.py
And this is the output:
46 INFO: PyInstaller: 3.5
46 INFO: Python: 3.8.0
46 INFO: Platform: Windows-10-10.0.17763-SP0
62 INFO: wrote F:\Python\Python Scripts\Pyinstaller\Py installer test\hello_world.spec
78 INFO: UPX is not available.
78 INFO: Extending PYTHONPATH with paths
['F:\\Python\\Python Scripts\\Pyinstaller\\Py installer test',
'F:\\Python\\Python Scripts\\Pyinstaller\\Py installer test']
78 INFO: checking Analysis
78 INFO: Building Analysis because Analysis-00.toc is non existent
78 INFO: Initializing module dependency graph...
93 INFO: Initializing module graph hooks...
93 INFO: Analyzing base_library.zip ...
3592 INFO: running Analysis Analysis-00.toc
3592 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\users\l&a\appdata\local\programs\python\python38\python.exe
4014 INFO: Caching module hooks...
4014 INFO: Analyzing F:\Python\Python Scripts\Pyinstaller\Py installer test\hello_world.py
4045 INFO: Loading module hooks...
4045 INFO: Loading module hook "hook-encodings.py"...
4202 INFO: Loading module hook "hook-pydoc.py"...
4202 INFO: Loading module hook "hook-xml.py"...
4405 INFO: Looking for ctypes DLLs
4420 INFO: Analyzing run-time hooks ...
4420 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
4420 INFO: Looking for dynamic libraries
5592 INFO: Looking for eggs
5592 INFO: Using Python library c:\users\l&a\appdata\local\programs\python\python38\python38.dll
5592 INFO: Found binding redirects:
[]
5592 INFO: Warnings written to F:\Python\Python Scripts\Pyinstaller\Py installer test\build\hello_world\warn-hello_world.txt
5670 INFO: Graph cross-reference written to F:\Python\Python Scripts\Pyinstaller\Py installer test\build\hello_world\xref-hello_world.html
5686 INFO: checking PYZ
5686 INFO: Building PYZ because PYZ-00.toc is non existent
5686 INFO: Building PYZ (ZlibArchive) F:\Python\Python Scripts\Pyinstaller\Py installer test\build\hello_world\PYZ-00.pyz
Traceback (most recent call last):
File "c:\users\l&a\appdata\local\programs\python\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\l&a\appdata\local\programs\python\python38\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\L&A\AppData\Local\Programs\Python\Python38\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\build_main.py", line 844, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\build_main.py", line 791, in build
exec(code, spec_namespace)
File "F:\Python\Python Scripts\Pyinstaller\Py installer test\hello_world.spec", line 18, in <module>
pyz = PYZ(a.pure, a.zipped_data,
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\api.py", line 98, in __init__
self.__postinit__()
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
self.assemble()
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\api.py", line 128, in assemble
self.code_dict = {
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\api.py", line 129, in <dictcomp>
key: strip_paths_in_code(code)
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\utils.py", line 652, in strip_paths_in_code
consts = tuple(
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\utils.py", line 653, in <genexpr>
strip_paths_in_code(const_co, new_filename)
File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\utils.py", line 660, in strip_paths_in_code
return code_func(co.co_argcount, co.co_kwonlyargcount, co.co_nlocals, co.co_stacksize,
TypeError: an integer is required (got type bytes)
This creates folders called 'dist' and 'build' and a file called 'hello_world.spec' but the 'dist' folder is empty. What is going wrong?
I search for
TypeError: an integer is required (got type bytes)
Did you read this?
I had this issue in the past, can you please perform the follwing:
open Anaconda prompt or any other IDE per example spyder or Atom terminal, command line as admin and Navigate to the folder where the .py located and run the command as bellow:
In my example the file I want to compile it is getwindowsversion.py
this is will create just standalone .exe can be used,
pyinstaller --onefile getwindowsversion.py
if you want to create regular build,
pyinstaller getwindowsversion.py

PyInstaller Django compilation <frozen importlib._bootstrap>

I'm trying to compile my django Project With PyInstaller, cuz of be safe in a shared disk driver That every One can review My Code.
and when Compile I get this output:
(env) D:__DEV__>pyinstaller Chortke/manage.py --onedir
222 INFO: PyInstaller: 4.0.dev0+46286a1f4
222 INFO: Python: 3.7.4 (conda)
222 INFO: Platform: Windows-10-10.0.16299-SP0
222 INFO: wrote D:\__DEV__\manage.spec
222 INFO: UPX is not available.
239 INFO: Extending PYTHONPATH with paths
['D:\\__DEV__\\Chortke', 'D:\\__DEV__']
239 INFO: checking Analysis
239 INFO: Building Analysis because Analysis-00.toc is non existent
239 INFO: Initializing module dependency graph...
244 INFO: Caching module graph hooks...
256 INFO: Analyzing base_library.zip ...
6561 INFO: Caching module dependency graph...
6664 INFO: running Analysis Analysis-00.toc
6679 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\users\mab\.conda\envs\env\python.exe
7249 INFO: Analyzing D:\__DEV__\Chortke\manage.py
7307 INFO: Processing pre-find module path hook distutils
7311 INFO: distutils: retargeting to non-venv dir 'c:\\users\\mab\\.conda\\envs\\env\\lib'
8887 INFO: Processing pre-find module path hook site
8887 INFO: site: retargeting to fake-dir 'c:\\users\\mab\\.conda\\envs\\env\\lib\\site-packages\\PyInstaller\\fake-modules'
15264 INFO: Processing module hooks...
15264 INFO: Loading module hook "hook-distutils.py"...
15264 INFO: Loading module hook "hook-django.core.cache.py"...
15439 INFO: Loading module hook "hook-django.core.mail.py"...
15601 INFO: Loading module hook "hook-django.core.management.py"...
15634 INFO: Import to be excluded not found: 'tkinter'
15635 INFO: Import to be excluded not found: 'IPython'
15635 INFO: Import to be excluded not found: 'matplotlib'
15635 INFO: Loading module hook "hook-django.db.backends.py"...
17084 WARNING: Hidden import "django.db.backends.__pycache__.base" not found!
17084 INFO: Loading module hook "hook-django.py"...
Traceback (most recent call last):
File "<string>", line 41, in <module>
File "<string>", line 36, in walk_packages
File "<string>", line 36, in walk_packages
File "<string>", line 20, in walk_packages
File "c:\users\mab\.conda\envs\env\lib\site-packages\django\contrib\gis\admin\__init__.py", line 5, in <module>
from django.contrib.gis.admin.options import GeoModelAdmin, OSMGeoAdmin
File "c:\users\mab\.conda\envs\env\lib\site-packages\django\contrib\gis\admin\options.py", line 2, in <module>
from django.contrib.gis.admin.widgets import OpenLayersWidget
File "c:\users\mab\.conda\envs\env\lib\site-packages\django\contrib\gis\admin\widgets.py", line 3, in <module>
from django.contrib.gis.gdal import GDALException
File "c:\users\mab\.conda\envs\env\lib\site-packages\django\contrib\gis\gdal\__init__.py", line 28, in <module>
from django.contrib.gis.gdal.datasource import DataSource
File "c:\users\mab\.conda\envs\env\lib\site-packages\django\contrib\gis\gdal\datasource.py", line 39, in <module>
from django.contrib.gis.gdal.driver import Driver
File "c:\users\mab\.conda\envs\env\lib\site-packages\django\contrib\gis\gdal\driver.py", line 5, in <module>
from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
File "c:\users\mab\.conda\envs\env\lib\site-packages\django\contrib\gis\gdal\prototypes\ds.py", line 9, in <module>
from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
File "c:\users\mab\.conda\envs\env\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 43, in <module>
% '", "'.join(lib_names)
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal203", "gdal202", "gdal201", "gdal20", "gdal111"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
19403 INFO: Determining a mapping of distributions to packages...
24054 INFO: Packages required by django:
['sqlparse', 'pytz']
24054 INFO: Django root directory D:\__DEV__\Chortke\chortke
Traceback (most recent call last):
File "c:\users\mab\.conda\envs\env\lib\site-packages\PyInstaller\utils\hooks\subproc\django_import_finder.py", line 37, in <module>
list(settings.TEMPLATE_LOADERS) + \
File "c:\users\mab\.conda\envs\env\lib\site-packages\django\conf\__init__.py", line 80, in __getattr__
val = getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'TEMPLATE_CONTEXT_PROCESSORS'
25398 INFO: Collecting Django migration scripts.
31358 INFO: Loading module hook "hook-encodings.py"...
31458 INFO: Loading module hook "hook-PIL.Image.py"...
32433 INFO: Loading module hook "hook-PIL.py"...
32433 INFO: Excluding import 'PySide'
32433 INFO: Removing import of PySide from module PIL.ImageQt
32449 INFO: Excluding import 'PyQt4'
32452 INFO: Removing import of PyQt4 from module PIL.ImageQt
32452 INFO: Excluding import 'PyQt5'
32454 INFO: Removing import of PyQt5 from module PIL.ImageQt
32455 INFO: Excluding import 'tkinter'
32458 INFO: Removing import of tkinter from module PIL.ImageTk
32458 INFO: Import to be excluded not found: 'FixTk'
32458 INFO: Loading module hook "hook-PIL.SpiderImagePlugin.py"...
32460 INFO: Excluding import 'tkinter'
32462 INFO: Import to be excluded not found: 'FixTk'
32462 INFO: Loading module hook "hook-pkg_resources.py"...
32934 INFO: Processing pre-safe import module hook win32com
Traceback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'win32com'
33011 INFO: Processing pre-safe import module hook win32com
Traceback (most recent call last):
File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'win32com'
33134 INFO: Excluding import '__main__'
33136 INFO: Removing import of __main__ from module pkg_resources
33136 INFO: Loading module hook "hook-pydoc.py"...
33137 INFO: Loading module hook "hook-pytz.py"...
33208 INFO: Loading module hook "hook-sqlite3.py"...
33307 INFO: Loading module hook "hook-sysconfig.py"...
33307 INFO: Loading module hook "hook-xml.dom.domreg.py"...
33307 INFO: Loading module hook "hook-xml.py"...
33307 INFO: Loading module hook "hook-_tkinter.py"...
33579 INFO: checking Tree
33579 INFO: Building Tree because Tree-00.toc is non existent
33579 INFO: Building Tree Tree-00.toc
33663 INFO: checking Tree
33663 INFO: Building Tree because Tree-01.toc is non existent
33663 INFO: Building Tree Tree-01.toc
33683 INFO: Loading module hook "hook-django.db.backends.mysql.base.py"...
33697 INFO: Loading module hook "hook-django.db.backends.oracle.base.py"...
33806 INFO: Looking for ctypes DLLs
33894 INFO: Analyzing run-time hooks ...
33900 INFO: Including run-time hook 'pyi_rth_pkgres.py'
33901 INFO: Including run-time hook 'pyi_rth_django.py'
33907 INFO: Looking for dynamic libraries
34271 INFO: Looking for eggs
34271 INFO: Using Python library c:\users\mab\.conda\envs\env\python37.dll
34271 INFO: Found binding redirects:
[]
34271 INFO: Warnings written to D:\__DEV__\build\manage\warn-manage.txt
34435 INFO: Graph cross-reference written to D:\__DEV__\build\manage\xref-manage.html
34710 INFO: checking PYZ
34710 INFO: Building PYZ because PYZ-00.toc is non existent
34710 INFO: Building PYZ (ZlibArchive) D:\__DEV__\build\manage\PYZ-00.pyz
35823 INFO: Building PYZ (ZlibArchive) D:\__DEV__\build\manage\PYZ-00.pyz completed successfully.
35874 INFO: checking PKG
35875 INFO: Building PKG because PKG-00.toc is non existent
35875 INFO: Building PKG (CArchive) PKG-00.pkg
35896 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
35904 INFO: Bootloader c:\users\mab\.conda\envs\env\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
35904 INFO: checking EXE
35904 INFO: Building EXE because EXE-00.toc is non existent
35905 INFO: Building EXE from EXE-00.toc
35905 INFO: Appending archive to EXE D:\__DEV__\build\manage\manage.exe
36000 INFO: Building EXE from EXE-00.toc completed successfully.
36014 INFO: checking COLLECT
36015 INFO: Building COLLECT because COLLECT-00.toc is non existent
36015 INFO: Building COLLECT COLLECT-00.toc
134331 INFO: Building COLLECT COLLECT-00.toc completed successfully.
And When i Run the exe file, I get this Error:
(env) D:__DEV__>dist\manage\manage.exe runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "threading.py", line 926, in _bootstrap_inner
File "threading.py", line 870, in run
File "site-packages\django\utils\autoreload.py", line 54, in wrapper
File "D:\__DEV__\dist\manage\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "site-packages\django\utils\autoreload.py", line 77, in raise_last_exception
File "site-packages\django\core\management\__init__.py", line 337, in execute
File "site-packages\django\utils\autoreload.py", line 54, in wrapper
File "site-packages\django\__init__.py", line 24, in setup
File "site-packages\django\apps\registry.py", line 91, in populate
File "site-packages\django\apps\config.py", line 90, in create
File "importlib\__init__.py", line 127, in import_module
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'django_admin_select2'
Traceback (most recent call last):
File "manage.py", line 15, in <module>
File "site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
File "site-packages\django\core\management\__init__.py", line 375, in execute
File "site-packages\django\core\management\base.py", line 323, in run_from_argv
File "D:\__DEV__\dist\manage\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "site-packages\django\core\management\base.py", line 364, in execute
File "D:\__DEV__\dist\manage\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "D:\__DEV__\dist\manage\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "site-packages\django\utils\autoreload.py", line 598, in run_with_reloader
File "site-packages\django\utils\autoreload.py", line 583, in start_django
File "site-packages\django\utils\autoreload.py", line 301, in run
File "site-packages\django\utils\autoreload.py", line 307, in run_loop
File "site-packages\django\utils\autoreload.py", line 347, in tick
File "site-packages\django\utils\autoreload.py", line 363, in snapshot_files
File "site-packages\django\utils\autoreload.py", line 262, in watched_files
File "site-packages\django\utils\autoreload.py", line 103, in iter_all_python_module_files
File "site-packages\django\utils\autoreload.py", line 139, in iter_modules_and_files
File "pathlib.py", line 1346, in exists
File "pathlib.py", line 1168, in stat
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '<frozen importlib._bootstrap>'
[5108] Failed to execute script manage
Plugins that installed:
(env) D:__DEV__>pip freeze
altgraph==0.16.1
astroid==2.2.5
backports.csv==1.0.7
certifi==2019.6.16
colorama==0.4.1
defusedxml==0.6.0
diff-match-patch==20181111
Django==2.2.4
django-admin-rangefilter==0.5.0
django-admin-select2==1.0.1
django-import-export==1.2.0
django-jalali==3.1.0
django-modeladmin-reorder==0.3.1
django-nested-admin==3.2.3
et-xmlfile==1.0.1
Faker==1.0.7
future==0.17.1
isort==4.3.21
jdatetime==3.2.0
jdcal==1.4.1
lazy-object-proxy==1.4.1
mccabe==0.6.1
odfpy==1.4.0
openpyxl==2.6.2
pefile==2019.4.18
Pillow==6.1.0
PyInstaller==4.0.dev0+46286a1f4
pylint==2.3.1
python-dateutil==2.8.0
python-monkey-business==1.0.0
pytz==2019.2
pywin32-ctypes==0.2.0
PyYAML==5.1.2
six==1.12.0
sqlparse==0.3.0
tablib==0.13.0
text-unidecode==1.2
typed-ast==1.4.0
wincertstore==0.2
wrapt==1.11.2
xlrd==1.2.0
xlwt==1.3.0
In my system i used to downgrade the django version from 2.2 to 1.8 in pyinstaller 3.4 version(pyinstaller 3.5 leads to kind of numpy error). Afterwards this error was resolved.
Refer this link
Django Middleware Error - Middleware changed for 1.7

While compiling .exe from .py file, how to fix ''ImportError: DLL load failed"?

I am new in programming. I have a Python code (named "adm_dicing.py") that includes some modules (numpy, scipy, matplotlib, etc.) and some others written by myself. It does some calculation and plot some figures (I haven't write if name = main in my code). When I compile the code on command line of Windows (I have windows 7) by entering:
"C:\ProgramData\Anaconda3\Scripts\pyinstaller.exe" adm_dicing.py
I got a mere .spec file, containing:
# -*- mode: python -*-
block_cipher = None
a = Analysis(['adm_dicing.py'],
pathex=['E:\\XiaoZhang\\Projet_R4-8_endoscope\\python codes'],
binaries=[],
datas=[],
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='adm_dicing',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='adm_dicing')
and in the command line I have the following message and errors:
483 INFO: PyInstaller: 3.4
483 INFO: Python: 3.7.3
483 INFO: Platform: Windows-7-6.1.7601-SP1
483 INFO: wrote E:\XiaoZhang\Projet_R4-8_endoscope\python codes\adm_dicing.spec
499 INFO: UPX is not available.
500 INFO: Extending PYTHONPATH with paths
['E:\\XiaoZhang\\Projet_R4-8_endoscope\\python codes',
'E:\\XiaoZhang\\Projet_R4-8_endoscope\\python codes']
500 INFO: checking Analysis
500 INFO: Building Analysis because Analysis-00.toc is non existent
500 INFO: Initializing module dependency graph...
507 INFO: Initializing module graph hooks...
566 INFO: Analyzing base_library.zip ...
15208 INFO: running Analysis Analysis-00.toc
15253 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of
final executable
required by C:\ProgramData\Anaconda3\python.exe
16945 INFO: Caching module hooks...
16959 INFO: Analyzing E:\XiaoZhang\Projet_R4-8_endoscope\python codes\adm_dicing
.py
22825 INFO: Processing pre-find module path hook distutils
23711 INFO: Processing pre-safe import module hook six.moves
33828 INFO: Processing pre-safe import module hook setuptools.extern.six.moves
36851 INFO: Processing pre-find module path hook site
36866 INFO: site: retargeting to fake-dir 'C:\\ProgramData\\Anaconda3\\lib\\site
-packages\\pyinstaller-3.4-py3.7.egg\\PyInstaller\\fake-modules'
99586 INFO: Processing pre-safe import module hook urllib3.packages.six.moves
162520 INFO: Processing pre-safe import module hook win32com
302047 INFO: Loading module hooks...
302047 INFO: Loading module hook "hook-babel.py"...
314303 INFO: Loading module hook "hook-bokeh.py"...
314694 INFO: Loading module hook "hook-certifi.py"...
314694 INFO: Loading module hook "hook-cryptography.py"...
316382 INFO: Loading module hook "hook-cytoolz.itertoolz.py"...
316401 INFO: Loading module hook "hook-distutils.py"...
316408 INFO: Loading module hook "hook-docutils.py"...
324213 INFO: Loading module hook "hook-encodings.py"...
324774 INFO: Loading module hook "hook-h5py.py"...
324786 INFO: Loading module hook "hook-IPython.py"...
324929 INFO: Excluding import 'matplotlib'
324945 INFO: Removing import of matplotlib.pyplot from module IPython.core.pyl
abtools
324945 INFO: Removing import of matplotlib from module IPython.core.pylabtools
324945 INFO: Removing import of matplotlib.figure from module IPython.core.pyl
abtools
324945 INFO: Removing import of matplotlib._pylab_helpers from module IPython.
core.pylabtools
324945 INFO: Excluding import 'PyQt5'
324945 INFO: Removing import of PyQt5 from module IPython.external.qt_loaders
324945 INFO: Removing import of PyQt5.QtWidgets from module IPython.external.q
t_loaders
324945 INFO: Removing import of PyQt5.QtGui from module IPython.external.qt_lo
aders
324945 INFO: Removing import of PyQt5.QtSvg from module IPython.external.qt_lo
aders
324945 INFO: Removing import of PyQt5.QtCore from module IPython.external.qt_l
oaders
324945 INFO: Excluding import 'PyQt4'
324960 INFO: Removing import of PyQt4 from module IPython.external.qt_loaders
324976 INFO: Excluding import 'PySide'
324976 INFO: Removing import of PySide from module IPython.external.qt_loaders
324976 INFO: Excluding import 'tkinter'
324991 INFO: Removing import of tkinter from module IPython.lib.clipboard
324991 INFO: Excluding import 'gtk'
324991 INFO: Loading module hook "hook-jedi.py"...
325023 INFO: Loading module hook "hook-jinja2.py"...
325038 INFO: Loading module hook "hook-jsonschema.py"...
325054 INFO: Loading module hook "hook-lib2to3.py"...
325085 INFO: Loading module hook "hook-lxml.etree.py"...
325085 INFO: Loading module hook "hook-matplotlib.backends.py"...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py", line
141, in <module>
from . import cbook, rcsetup
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\cbook\__init__.py"
, line 33, in <module>
import numpy as np
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py", line 140,
in <module>
from . import _distributor_init
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\_distributor_init.py",
line 34, in <module>
from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.
325986 INFO: Loading module hook "hook-matplotlib.py"...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py", line
141, in <module>
from . import cbook, rcsetup
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\cbook\__init__.py"
, line 33, in <module>
import numpy as np
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py", line 140,
in <module>
from . import _distributor_init
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\_distributor_init.py",
line 34, in <module>
from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.
327061 INFO: Loading module hook "hook-numpy.core.py"...
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py", line 140,
in <module>
from . import _distributor_init
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\_distributor_init.py",
line 34, in <module>
from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\pkgutil.py", line 493, in find_loader
spec = importlib.util.find_spec(fullname)
File "C:\ProgramData\Anaconda3\lib\importlib\util.py", line 94, in find_spec
parent = __import__(parent_name, fromlist=['__path__'])
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py", line 140,
in <module>
from . import _distributor_init
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\_distributor_init.py",
line 34, in <module>
from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\pyinstaller-3.4-py3.7.egg\PyI
nstaller\utils\hooks\__init__.py", line 320, in get_module_file_attribute
loader = pkgutil.find_loader(package)
File "C:\ProgramData\Anaconda3\lib\pkgutil.py", line 499, in find_loader
raise ImportError(msg.format(fullname, type(ex), ex)) from ex
ImportError: Error while finding loader for 'numpy.core' (<class 'ImportError'>:
DLL load failed: The specified module could not be found.)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\pyinstaller-script.py", line 11, in <mo
dule>
load_entry_point('PyInstaller==3.4', 'console_scripts', 'pyinstaller')()
File "C:\ProgramData\Anaconda3\lib\site-packages\pyinstaller-3.4-py3.7.egg\PyI
nstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:\ProgramData\Anaconda3\lib\site-packages\pyinstaller-3.4-py3.7.egg\PyI
nstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\pyinstaller-3.4-py3.7.egg\PyI
nstaller\building\build_main.py", line 838, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'
))
File "C:\ProgramData\Anaconda3\lib\site-packages\pyinstaller-3.4-py3.7.egg\PyI
nstaller\building\build_main.py", line 784, in build
exec(text, spec_namespace)
File "<string>", line 17, in <module>
File "C:\ProgramData\Anaconda3\lib\site-packages\pyinstaller-3.4-py3.7.egg\PyI
nstaller\building\build_main.py", line 241, in __init__
self.__postinit__()
File "C:\ProgramData\Anaconda3\lib\site-packages\pyinstaller-3.4-py3.7.egg\PyI
nstaller\building\datastruct.py", line 158, in __postinit__
self.assemble()
File "C:\ProgramData\Anaconda3\lib\site-packages\pyinstaller-3.4-py3.7.egg\PyI
nstaller\building\build_main.py", line 500, in assemble
module_hook.post_graph()
File "C:\ProgramData\Anaconda3\lib\site-packages\pyinstaller-3.4-py3.7.egg\PyI
nstaller\building\imphook.py", line 410, in post_graph
self._load_hook_module()
File "C:\ProgramData\Anaconda3\lib\site-packages\pyinstaller-3.4-py3.7.egg\PyI
nstaller\building\imphook.py", line 377, in _load_hook_module
self.hook_module_name, self.hook_filename)
File "C:\ProgramData\Anaconda3\lib\site-packages\pyinstaller-3.4-py3.7.egg\PyI
nstaller\compat.py", line 736, in importlib_load_source
return mod_loader.load_module()
File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrappe
r
File "<frozen importlib._bootstrap_external>", line 907, in load_module
File "<frozen importlib._bootstrap_external>", line 732, in load_module
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
File "<frozen importlib._bootstrap>", line 696, in _load
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\ProgramData\Anaconda3\lib\site-packages\pyinstaller-3.4-py3.7.egg\PyI
nstaller\hooks\hook-numpy.core.py", line 27, in <module>
pkg_base, pkg_dir = get_package_paths('numpy.core')
File "C:\ProgramData\Anaconda3\lib\site-packages\pyinstaller-3.4-py3.7.egg\PyI
nstaller\utils\hooks\__init__.py", line 537, in get_package_paths
file_attr = get_module_file_attribute(package)
File "C:\ProgramData\Anaconda3\lib\site-packages\pyinstaller-3.4-py3.7.egg\PyI
nstaller\utils\hooks\__init__.py", line 339, in get_module_file_attribute
raise ImportError
ImportError
How can I fix the problem?
Note that I have installed pywin, the last Windows Visual Studio (but not any extensions yet)
EDIT : I tried with a code that contains no imported modules, it works fine. As long as I include something like "import numpy as np", things go wrong...

Categories