1
votes

I'm trying to use pyinstaller to create an single exe file of my Python program, but when the process completes, the exe can't be run. After reviewing the console output from the process, I can see that following the line:

126946 INFO: Looking for dynamic libraries

I get several hundred lines of "WARNING: lib not found: api-ms-win-crt-any number of different .dll dependency of path to where the dll or pyd is saved

I installed Python using a default configuration and have always installed Python packages using pip. Pyinstaller is supposed to be straight-forward and not need a lot of extra steps, like creating a setup.py file, but it seems something is missing which tells pyinstaller where to look for those missing libraries. Is there a workaround for this? Or even a better python to exe compiler that I should use?

EDIT: To provide more info - My program is made up of 5 modules, and among those I use three 3rd party packages including: PyQt5, pandas and ArcGIS. Additionally, I have two sql files that are part of the program as well. I have a feeling that pyinstaller can only compile simple scripts and by using other packages, modules and external files, it just it's made to handle that kind of stuff.

3
can you show us the command you used to create single exeInAFlash
Initially, I just entered pyinstaller myFile.py into the console, while in the directory of myFile.py. Since I wanted to just have a self contained exe, I changed it to: pyinstaller --onedir --name=myFile --windowed --onefile --noconsole myFile.pyNL23codes
@ishandutta2007 That looks like an entirely different issue, since the error message references a different missing library and problem.NL23codes
@NLee23 libpython2.7.dylib dylib stands for dynamic library. In both case library is present and is in appropiate path but the code is not able to accessishandutta2007

3 Answers

1
votes

funny that someone asked a similar question ~44mins ago but using python with excel.

Anyway, hope this answer here works and the auditor/moderator doesn't freak out about it ;p

I've copied the instructions from the my recommended solution and used the link as supplementary. https://www.youtube.com/watch?v=OZSZHmWSOeM

Py to exe Project

Prerequisites

Python : Python 2.7 or Python 3.3+ (basically anything that pyinstaller runs on)

Chrome : to run the user interface

Installing

Download the zipped folder

Open cmd/terminal and cd to unzipped folder (recommend putting it on your desktop for now)

Execute pip install -r requirements.txt

Running the Application

Run run.py. Chrome will open in app mode with the project running inside.

Using the Application

Select your script location (paste in or use the file explorer)

Address-box outline will become blue when file exists

Select other options and add things like an icon or other files

Click the big blue button at the bottom to convert

Find your converted files in [unzipped folder]/output when completed

Passing the File With Arguments

Alternatively you can execute python run.py [filename]. This will open up the window with the filename in the script location.

0
votes

You need to install the Windows 10 SDK and then update your Path to include the ucrt dlls, which may be found here post-installation:

C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x86

0
votes

I made a series of changes which resulted in the build compiling and running correctly.

First, pyinstaller is missing a 'hook' file for pandas, so one must be manually created. For me the hook folder was located here: "C:\Users\natha\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\PyInstaller\hooks"

Inside that folder I created a file named hook-pandas.py and the only contents of that file was one line: hiddenimports = ['pandas._libs.tslibs.timedeltas']

I did install the Windows 10 SDK, but I'm not sure if that was just part of the problem, or what it affected if anything. My program was made up of multiple modules, because I like to separate different types of processes in different files. However, to simplify things I combined all my code to one .py file and had just one other file that contained my PyQt5/Qt Designer auto-generated GUI code. I removed all imports that read like

from x.y import z 

I received errors in a few builds where it seemed like pyinstaller didn't recognize those things. So I kept things very straight-forward, like

import PyQt5

Lastly, when I went to compile the build, using the -p command, I added two file paths; one pointed to the root location of my program, which is where the other module(the PyQt5 module) was saved and the second path was to "C:\Users\natha\AppData\Local\Programs\Python\Python36-32\Lib\site-packages". Once these things are in place, compile completed normally and the build runs perfectly. So in summary, the keys to success here are:

-Ensure there is a hook-pandas.py file IF pandas is being used in your script -Ensure the hook-pandas.py file contains this line:

hiddenimports = ['pandas._libs.tslibs.timedeltas']

-And be sure -p command is used to direct pyinstaller to where your custom modules and any python packages are saved. My -p command read like this:

-p C:\Users\natha\Desktop\Python_Projects\CompEval\code:C:\Users\natha\AppData\Local\Programs\Python\Python36-32\Lib\site-packages

Notice the colon separating the two paths.

I think those are the main things to check for and secondary things would be the

from x.y import z

type imports, to avoid those.