Problem using numpy and pyinstaller

25 views
Skip to first unread message

Jose Casas

unread,
Jul 16, 2019, 5:38:30 AM7/16/19
to PyInstaller
Hello,

I am using pysinstaller very last version: 4.0.dev0+7350d4c85 but this happends with older versions too.

When I generate an app that contains numpy in windows 7 by doing:

import subprocess

# -y remove previous content of folder

#command = "pyinstaller.exe -y --hidden-import numpy test1.py"
command = "pyinstaller.exe -y test1.py"

proc = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
out, err = proc.communicate()

I get the error:


5713 INFO: Processing pre-safe import module hook   setuptools.extern.six.moves
Traceback (most recent call last):
  File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'setuptools._vendor'
Traceback (most recent call last):
  File "C:\workspaces\pysival_jose\pepis_gui\pyinstaller-script.py", line 11, in <module>
    load_entry_point('PyInstaller==3.4', 'console_scripts', 'pyinstaller')()
  File "C:\Python36\lib\site-packages\PyInstaller\__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Python36\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Python36\lib\site-packages\PyInstaller\building\build_main.py", line 838, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "C:\Python36\lib\site-packages\PyInstaller\building\build_main.py", line 784, in build
    exec(text, spec_namespace)
  File "<string>", line 17, in <module>
  File "C:\Python36\lib\site-packages\PyInstaller\building\build_main.py", line 241, in __init__
    self.__postinit__()
  File "C:\Python36\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
    self.assemble()
  File "C:\Python36\lib\site-packages\PyInstaller\building\build_main.py", line 443, in assemble
    priority_scripts.append(self.graph.run_script(script))
  File "C:\Python36\lib\site-packages\PyInstaller\depend\analysis.py", line 201, in run_script
    self._top_script_node = super(PyiModuleGraph, self).run_script(pathname)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1348, in run_script
    self._scan_code(m, co, co_ast)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2544, in _scan_code
    self._process_imports(module)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2743, in _process_imports
    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2221, in _safe_import_hook
    target_attr_names=None, level=level, edge_attr=edge_attr)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1421, in import_hook
    source_package, target_module_partname, level)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1573, in _find_head_package
    target_module_headname, target_package_name, source_package)
  File "C:\Python36\lib\site-packages\PyInstaller\depend\analysis.py", line 271, in _safe_import_module
    module_basename, module_name, parent_package)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1990, in _safe_import_module
    module_name, file_handle, pathname, metadata)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2028, in _load_module
    m = self._load_package(fqname, pathname, packagepath)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2813, in _load_package
    self._load_module(fqname, fp, buf, stuff)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2082, in _load_module
    self._scan_code(m, co, co_ast)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2544, in _scan_code
    self._process_imports(module)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2743, in _process_imports
    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2417, in _safe_import_hook
    edge_attr=edge_attr)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1438, in import_hook
    target_module, target_attr_names):
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1726, in _import_importable_package_submodules
    attr_name, submodule_name, package)
  File "C:\Python36\lib\site-packages\PyInstaller\depend\analysis.py", line 271, in _safe_import_module
    module_basename, module_name, parent_package)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1990, in _safe_import_module
    module_name, file_handle, pathname, metadata)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2028, in _load_module
    m = self._load_package(fqname, pathname, packagepath)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2813, in _load_package
    self._load_module(fqname, fp, buf, stuff)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2082, in _load_module
    self._scan_code(m, co, co_ast)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2544, in _scan_code
    self._process_imports(module)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2743, in _process_imports
    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2221, in _safe_import_hook
    target_attr_names=None, level=level, edge_attr=edge_attr)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1422, in import_hook
    target_module = self._load_tail(target_package, target_module_partname)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1635, in _load_tail
    submodule = self._safe_import_module(head, mname, submodule)
  File "C:\Python36\lib\site-packages\PyInstaller\depend\analysis.py", line 271, in _safe_import_module
    module_basename, module_name, parent_package)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1990, in _safe_import_module
    module_name, file_handle, pathname, metadata)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2082, in _load_module
    self._scan_code(m, co, co_ast)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2544, in _scan_code
    self._process_imports(module)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2743, in _process_imports
    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2221, in _safe_import_hook
    target_attr_names=None, level=level, edge_attr=edge_attr)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1422, in import_hook
    target_module = self._load_tail(target_package, target_module_partname)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1635, in _load_tail
    submodule = self._safe_import_module(head, mname, submodule)
  File "C:\Python36\lib\site-packages\PyInstaller\depend\analysis.py", line 271, in _safe_import_module
    module_basename, module_name, parent_package)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1990, in _safe_import_module
    module_name, file_handle, pathname, metadata)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2028, in _load_module
    m = self._load_package(fqname, pathname, packagepath)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2813, in _load_package
    self._load_module(fqname, fp, buf, stuff)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2082, in _load_module
    self._scan_code(m, co, co_ast)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2544, in _scan_code
    self._process_imports(module)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2743, in _process_imports
    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2417, in _safe_import_hook
    edge_attr=edge_attr)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1438, in import_hook
    target_module, target_attr_names):
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1726, in _import_importable_package_submodules
    attr_name, submodule_name, package)
  File "C:\Python36\lib\site-packages\PyInstaller\depend\analysis.py", line 271, in _safe_import_module
    module_basename, module_name, parent_package)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1990, in _safe_import_module
    module_name, file_handle, pathname, metadata)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2082, in _load_module
    self._scan_code(m, co, co_ast)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2544, in _scan_code
    self._process_imports(module)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2743, in _process_imports
    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2417, in _safe_import_hook
    edge_attr=edge_attr)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1438, in import_hook
    target_module, target_attr_names):
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1726, in _import_importable_package_submodules
    attr_name, submodule_name, package)
  File "C:\Python36\lib\site-packages\PyInstaller\depend\analysis.py", line 271, in _safe_import_module
    module_basename, module_name, parent_package)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1990, in _safe_import_module
    module_name, file_handle, pathname, metadata)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2082, in _load_module
    self._scan_code(m, co, co_ast)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2544, in _scan_code
    self._process_imports(module)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2743, in _process_imports
    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2221, in _safe_import_hook
    target_attr_names=None, level=level, edge_attr=edge_attr)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1421, in import_hook
    source_package, target_module_partname, level)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1573, in _find_head_package
    target_module_headname, target_package_name, source_package)
  File "C:\Python36\lib\site-packages\PyInstaller\depend\analysis.py", line 271, in _safe_import_module
    module_basename, module_name, parent_package)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1990, in _safe_import_module
    module_name, file_handle, pathname, metadata)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2082, in _load_module
    self._scan_code(m, co, co_ast)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2544, in _scan_code
    self._process_imports(module)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2743, in _process_imports
    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2221, in _safe_import_hook
    target_attr_names=None, level=level, edge_attr=edge_attr)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1422, in import_hook
    target_module = self._load_tail(target_package, target_module_partname)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1635, in _load_tail
    submodule = self._safe_import_module(head, mname, submodule)
  File "C:\Python36\lib\site-packages\PyInstaller\depend\analysis.py", line 271, in _safe_import_module
    module_basename, module_name, parent_package)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1990, in _safe_import_module
    module_name, file_handle, pathname, metadata)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2082, in _load_module
    self._scan_code(m, co, co_ast)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2544, in _scan_code
    self._process_imports(module)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2743, in _process_imports
    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2221, in _safe_import_hook
    target_attr_names=None, level=level, edge_attr=edge_attr)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1421, in import_hook
    source_package, target_module_partname, level)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1573, in _find_head_package
    target_module_headname, target_package_name, source_package)
  File "C:\Python36\lib\site-packages\PyInstaller\depend\analysis.py", line 271, in _safe_import_module
    module_basename, module_name, parent_package)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1990, in _safe_import_module
    module_name, file_handle, pathname, metadata)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2028, in _load_module
    m = self._load_package(fqname, pathname, packagepath)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2813, in _load_package
    self._load_module(fqname, fp, buf, stuff)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2082, in _load_module
    self._scan_code(m, co, co_ast)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2544, in _scan_code
    self._process_imports(module)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2743, in _process_imports
    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2221, in _safe_import_hook
    target_attr_names=None, level=level, edge_attr=edge_attr)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1422, in import_hook
    target_module = self._load_tail(target_package, target_module_partname)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1635, in _load_tail
    submodule = self._safe_import_module(head, mname, submodule)
  File "C:\Python36\lib\site-packages\PyInstaller\depend\analysis.py", line 271, in _safe_import_module
    module_basename, module_name, parent_package)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1990, in _safe_import_module
    module_name, file_handle, pathname, metadata)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2082, in _load_module
    self._scan_code(m, co, co_ast)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2544, in _scan_code
    self._process_imports(module)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2743, in _process_imports
    target_module = self._safe_import_hook(*import_info, **kwargs)[0]
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2221, in _safe_import_hook
    target_attr_names=None, level=level, edge_attr=edge_attr)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1422, in import_hook
    target_module = self._load_tail(target_package, target_module_partname)
  File "C:\Python36\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1635, in _load_tail
    submodule = self._safe_import_module(head, mname, submodule)
  File "C:\Python36\lib\site-packages\PyInstaller\depend\analysis.py", line 260, in _safe_import_module
    hook_module.pre_safe_import_module(hook_api)
  File "C:\Python36\lib\site-packages\PyInstaller\hooks\pre_safe_import_module\hook-setuptools.extern.six.moves.py", line 34, in pre_safe_import_module
    for real_module_name, six_module_name in real_to_six_module_name.items():
AttributeError: 'str' object has no attribute 'items'



My app is just:

import PySimpleGUI as sg
import numpy as np



a = np.array([[7,8,5],[3,5,7]])


# All the stuff inside your window. This is the PSG magic code compactor...
layout = [ [sg.Text('Some text on Row 1')],
[sg.Text('Enter something on Row 2'), sg.InputText()],
[sg.OK(), sg.Cancel()]]

# Create the Window
window = sg.Window('Window Title', layout)
# Event Loop to process "events"
while True:
event, values = window.Read()
print(event, values)
if event in (None, 'Cancel'):
break

window.Close()

Eric Fahlgren

unread,
Jul 16, 2019, 9:34:52 AM7/16/19
to pyins...@googlegroups.com
Looking in the source on github, it looks like that was fixed last October.  I think you need to update that hook file.  The "for" loop in my version is at line 40, not line 34...

--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyinstaller...@googlegroups.com.
To post to this group, send email to pyins...@googlegroups.com.
Visit this group at https://groups.google.com/group/pyinstaller.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/3270c890-ae35-4942-b071-247f1ef68ee7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages