Pyinstaller with pandas and numpy, exe throws error at runtime

Rishi

I am trying to make an EXE using Pyinstaller of a small test program. I made a virtual environment to make the exe size smaller as anaconda includes every library it has.

ERROR at run time:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
  File "c:\users\madanr\appdata\local\continuum\anaconda3\envs\pyin36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\pandas\__init__.py", line 19, in <module>
ImportError: Missing required dependencies ['numpy']
[15592] Failed to execute script test

I have already tried making a new environment with python35 and its the same error I installed numpy using pip and then installed all the other packages

test.py code:

import pandas as pd
import numpy as np

pdf = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD'))
print(pdf)

pip freeze for my environment(pyin36)

altgraph==0.16.1
certifi==2018.11.29
future==0.17.1
macholib==1.11
numpy==1.16.0
pandas==0.23.4
pefile==2018.8.8
PyInstaller==3.4
pyodbc==4.0.25
pypiwin32==223
python-dateutil==2.7.5
pytz==2018.9
pywin32==224
pywin32-ctypes==0.2.0
scipy==1.2.0
six==1.12.0
wincertstore==0.2

I am posting >pyinstaller test.py cmd output here

121 INFO: PyInstaller: 3.4
121 INFO: Python: 3.6.8
122 INFO: Platform: Windows-10-10.0.16299-SP0
130 INFO: wrote C:\Users\MadanR\Desktop\Python Executables\Test\test.spec
136 INFO: UPX is not available.
153 INFO: Extending PYTHONPATH with paths
['C:\\Users\\MadanR\\Desktop\\Python '
 'Executables\\Test',
 'C:\\Users\\MadanR\\Desktop\\Python '
 'Executables\\Test']
158 INFO: checking Analysis
161 INFO: Building Analysis because Analysis-00.toc is non existent
165 INFO: Initializing module dependency graph...
172 INFO: Initializing module graph hooks...
178 INFO: Analyzing base_library.zip ...
8026 INFO: running Analysis Analysis-00.toc
8031 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\madanr\appdata\local\continuum\anaconda3\envs\pyin36\python.exe
10193 INFO: Caching module hooks...
10216 INFO: Analyzing C:\Users\MadanR\Desktop\Python Executables\Test\test.py
10346 INFO: Processing pre-find module path hook   distutils
11180 INFO: Processing pre-safe import module hook   six.moves
17163 INFO: Processing pre-find module path hook   site
17164 INFO: site: retargeting to fake-dir 'c:\\users\\madanr\\appdata\\local\\continuum\\anaconda3\\envs\\pyin36\\lib\\site-packages\\PyInstaller\\fake-modules'
20521 INFO: Processing pre-safe import module hook   setuptools.extern.six.moves
39249 INFO: Loading module hooks...
39250 INFO: Loading module hook "hook-distutils.py"...
39268 INFO: Loading module hook "hook-encodings.py"...
39567 INFO: Loading module hook "hook-lib2to3.py"...
39584 INFO: Loading module hook "hook-numpy.core.py"...
39884 INFO: Loading module hook "hook-numpy.py"...
39895 INFO: Loading module hook "hook-pandas.py"...
41840 INFO: Loading module hook "hook-pkg_resources.py"...
42584 INFO: Processing pre-safe import module hook   win32com
42977 INFO: Loading module hook "hook-pydoc.py"...
42980 INFO: Loading module hook "hook-pythoncom.py"...
43610 INFO: Loading module hook "hook-pytz.py"...
43816 INFO: Loading module hook "hook-pywintypes.py"...
44355 INFO: Loading module hook "hook-scipy.linalg.py"...
44364 INFO: Loading module hook "hook-scipy.py"...
44382 INFO: Loading module hook "hook-scipy.sparse.csgraph.py"...
44395 INFO: Loading module hook "hook-scipy.special._ellip_harm_2.py"...
44397 INFO: Loading module hook "hook-scipy.special._ufuncs.py"...
44406 INFO: Loading module hook "hook-setuptools.py"...
45322 INFO: Loading module hook "hook-sqlite3.py"...
45543 INFO: Loading module hook "hook-sysconfig.py"...
45547 INFO: Loading module hook "hook-win32com.py"...
46118 INFO: Loading module hook "hook-xml.dom.domreg.py"...
46121 INFO: Loading module hook "hook-xml.py"...
46266 INFO: Looking for ctypes DLLs
46332 INFO: Analyzing run-time hooks ...
46348 INFO: Including run-time hook 'pyi_rth_pkgres.py'
46350 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
46357 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
46396 INFO: Looking for dynamic libraries
72892 INFO: Looking for eggs
72892 INFO: Using Python library c:\users\madanr\appdata\local\continuum\anaconda3\envs\pyin36\python36.dll
72899 INFO: Found binding redirects:
[]
72948 INFO: Warnings written to C:\Users\MadanR\Desktop\Python Executables\Test\build\test\warn-test.txt
73287 INFO: Graph cross-reference written to C:\Users\MadanRDesktop\Python Executables\Test\build\test\xref-test.html
73433 INFO: checking PYZ
73433 INFO: Building PYZ because PYZ-00.toc is non existent
73439 INFO: Building PYZ (ZlibArchive) C:\Users\MadanR\Desktop\Python Executables\Test\build\test\PYZ-00.pyz
77493 INFO: Building PYZ (ZlibArchive) C:\Users\MadanR\Desktop\Python Executables\Test\build\test\PYZ-00.pyz completed successfully.
77615 INFO: checking PKG
77616 INFO: Building PKG because PKG-00.toc is non existent
77622 INFO: Building PKG (CArchive) PKG-00.pkg
77794 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
77810 INFO: Bootloader c:\users\madanr\appdata\local\continuum\anaconda3\envs\pyin36\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
77811 INFO: checking EXE
77812 INFO: Building EXE because EXE-00.toc is non existent
77815 INFO: Building EXE from EXE-00.toc
77817 INFO: Appending archive to EXE C:\Users\MadanRDesktop\Python Executables\Test\build\test\test.exe
77921 INFO: Building EXE from EXE-00.toc completed successfully.
77945 INFO: checking COLLECT
77945 INFO: Building COLLECT because COLLECT-00.toc is non existent
77961 INFO: Building COLLECT COLLECT-00.toc
97895 INFO: Building COLLECT COLLECT-00.toc completed successfully.
Steven

There is definitely an issue between PyInstaller 3.4 and numpy 1.16 leading to the error you see. Until the issue is resolved, reverting numpy to 1.15.4 should work for you:

pip install numpy==1.15.4

Then rebuild your .exe with PyInstaller and try again.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Pandas, Numpy in PyInstaller

Runtime error when calling a .exe made with PyInstaller including PyQt4

PyInstaller exe gives cython error

How to handle a runtime error with throws

PyInstaller with Pandas creates over 500 MB exe

Getting a Runtime Error in Executable made with pyinstaller

PyInstaller exe returning error on a Tkinter script

Chromedriver Path Error when converting to .exe Pyinstaller

Error creating .exe (pyinstaller) with cloudscraper module [Python]

Python pyinstaller error when converting py to exe

Pyinstaller Error when running the exe file

How to fix error with pyinstaller after compilation in exe

Error handling middleware throws a runtime error

Numpy reshape with remainder throws error

asyncio throws runtime error with exception ignored

cout newly created object throws runtime error

pyinstaller - when freeze the app QtWebEngineWidgets throws dll error

Pyinstaller, tensorflow.contrib lazy loader error at runtime

error in running exe file having xgboost package by using pyinstaller

Anaconda Python, Pyinstaller 3.1.1, script to exe, run time error

PyInstaller .exe file terminates early without an error message

pyinstaller not creating .exe (ERROR: base_library.zip could not be created!)

Keep error message of exe file which is created by Pyinstaller

PyInstaller error when running exe with TensorFlow2 and Tkinter libraries

[RE]Can you see my pyinstaller error. There is no EXE file

Pyinstaller throws AssertionError

NumPy log function throws attribute error for int

numpy and pandas timedelta error

Reducing size of pyinstaller exe