question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: Pyinstaller fails to convert code with numpy

See original GitHub issue

I wrote a simple script that takes user input and creates a .txt. My first iteration only wrote to the file and did not other work on the file. I added numpy library for the genfromtxt and find features. the code runs perfectly, but when I try to convert to an .exe file it will not package. The only additions to the script is numpy, and the previous version without it packaged without issue.

I’m a pretty novice coder and this may not be a numpy issue, but this is my best reasonable guess.

Reproducing code example:

****NOT APPLICABLE: Error is in conversion from .py to .exe. The code runs fine in the editor (PyCharm).

Error message:

Running auto-py-to-exe v2.6.5
Building in the current instances temporary directory at C:\Users\adamt\AppData\Local\Temp\tmp6a58x7u8
To get a new temporary directory, restart this application
Recursion Limit is set to 5000
Executing: pyinstaller -y  "C:/Users/adamt/Desktop/QA Lot Tracking Application/QAInternalTrackingApp_v5.py"
60089327 INFO: PyInstaller: 3.5
60089330 INFO: Python: 3.7.0
60089330 INFO: Platform: Windows-10-10.0.18362-SP0
60089335 INFO: wrote C:\Users\adamt\AppData\Local\Temp\tmp6a58x7u8\QAInternalTrackingApp_v5.spec
60089348 INFO: UPX is not available.
60089373 INFO: Extending PYTHONPATH with paths
['C:\\Users\\adamt\\Desktop\\QA Lot Tracking Application',
 'C:\\Users\\adamt\\AppData\\Local\\Temp\\tmp6a58x7u8']
60089375 INFO: checking Analysis
60089375 INFO: Building Analysis because Analysis-01.toc is non existent
60089376 INFO: Initializing module dependency graph...
60089399 INFO: Initializing module graph hooks...
60089417 INFO: Analyzing base_library.zip ...
60093336 INFO: running Analysis Analysis-01.toc
60093340 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\program files\python37\python.exe
60094382 INFO: Caching module hooks...
60094400 INFO: Analyzing C:\Users\adamt\Desktop\QA Lot Tracking Application\QAInternalTrackingApp_v5.py
60094981 INFO: Processing pre-find module path hook   distutils
60096595 INFO: Processing pre-find module path hook   site
60096596 INFO: site: retargeting to fake-dir 'C:\\Users\\adamt\\AppData\\Roaming\\Python\\Python37\\site-packages\\PyInstaller\\fake-modules'
60099890 INFO: Processing pre-safe import module hook   setuptools.extern.six.moves
**60103279 INFO: Loading module hooks...
60103279 INFO: Loading module hook "hook-distutils.py"...
60103282 INFO: Loading module hook "hook-encodings.py"...
60103422 INFO: Loading module hook "hook-gevent.py"...
60103726 WARNING: Unable to find package for requirement greenlet from package gevent.
60103727 INFO: Packages required by gevent:
['cffi']
60104984 INFO: Loading module hook "hook-jinja2.py"...
60105008 INFO: Loading module hook "hook-lib2to3.py"...
60105017 INFO: Loading module hook "hook-numpy.core.py"...**
An error occurred, traceback follows:
Traceback (most recent call last):
  File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\auto_py_to_exe\__main__.py", line 269, in convert
    pyi.run() # Execute PyInstaller
  File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Users\adamt\AppData\Roaming\Python\Python37\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\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\build_main.py", line 791, in build
    exec(code, spec_namespace)
  File "C:\Users\adamt\AppData\Local\Temp\tmp6a58x7u8\QAInternalTrackingApp_v5.spec", line 17, in <module>
    noarchive=False)
  File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\build_main.py", line 243, in __init__
    self.__postinit__()
  File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
    self.assemble()
  File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\build_main.py", line 502, in assemble
    module_hook.post_graph()
  File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\imphook.py", line 410, in post_graph
    self._load_hook_module()
  File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\building\imphook.py", line 377, in _load_hook_module
    self.hook_module_name, self.hook_filename)
  File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\compat.py", line 793, 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\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\hooks\hook-numpy.core.py", line 27, in <module>
    pkg_base, pkg_dir = get_package_paths('numpy.core')
  File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\utils\hooks\__init__.py", line 535, in get_package_paths
    file_attr = get_module_file_attribute(package)
  File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\PyInstaller\utils\hooks\__init__.py", line 318, in get_module_file_attribute
    loader = pkgutil.find_loader(package)
  File "c:\program files\python37\lib\pkgutil.py", line 493, in find_loader
    spec = importlib.util.find_spec(fullname)
  File "c:\program files\python37\lib\importlib\util.py", line 94, in find_spec
    parent = __import__(parent_name, fromlist=['__path__'])
  File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\Users\adamt\AppData\Roaming\Python\Python37\site-packages\numpy\_distributor_init.py", line 26, in <module>
    WinDLL(os.path.abspath(filename))
  File "c:\program files\python37\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application

Project output will not be moved to output folder
Complete.

Numpy/Python version information:

<module ‘numpy.version’ from ‘C:\Users\adamt\Desktop\QA Lot Tracking Application\lib\site-packages\numpy\version.py’> 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)]

Name: numpy Version: 1.17.3

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mattipcommented, Nov 4, 2019

If numpy imports properly, I don’ t think we can really help you more. We did add some things for pyinstaller in numpy, but we are going to need someone who knows pyinstaller to figure this out. You may want to ask on their issue tracker or try digging in their documentation

0reactions
rossbarcommented, Jul 22, 2020

Closing due to inactivity. If the issue persists, please first check with the PyInstaller docs/issues linked above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't transform a python program into exe - Stack Overflow
I want to transform a simple .py code into .exe using PyInstaller, the program works fine with python, but when I transform it...
Read more >
When Things Go Wrong — PyInstaller 5.7.0 documentation
If Analysis thinks it has found all the imports, but the app fails with an import error, the problem is a hidden import;...
Read more >
Problems with Pyinstaller & and Common Fixes - YouTube
uite error prone, and many people have run into alot of constant errors and problems while using Pyinstaller. This Video was created for...
Read more >
How to convert Python file to .exe file | 3 ways to solve errors
Upgrade your pyinstaller version 3. Visualize error by opening your .exe file by displaying console If you still got problem, ...
Read more >
Using PyInstaller to Easily Distribute Python Applications
PyInstaller performs this amazing feat by introspecting your Python code, ... Now running the new executable will result in a new error about...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found