Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyInstaller WARNING: lib not found

I know this type of question has been asked here before, but I did not find a working solution to it. I have a python file which I want to convert to an exe on Windows 10. I ran pyinstaller --onefile --noconsole myfile.py, and it outputted a lot of warnings:

C:\Users\conne\Desktop\Python >pyinstaller --onefile --noconsole normal.py
277 INFO: PyInstaller: 3.3.1
277 INFO: Python: 3.6.2
278 INFO: Platform: Windows-10-10.0.15063-SP0
279 INFO: wrote C:\Users\conne\Desktop\Python\normal.spec
280 INFO: UPX is not available.
283 INFO: Extending PYTHONPATH with paths
['C:\\Users\\conne\\Desktop\\python',
 'C:\\Users\\conne\\Desktop\\python']
283 INFO: checking Analysis
284 INFO: Building Analysis because out00-Analysis.toc is non existent
284 INFO: Initializing module dependency graph...
286 INFO: Initializing module graph hooks...
289 INFO: Analyzing base_library.zip ...
5055 INFO: running Analysis out00-Analysis.toc
5058 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\conne\appdata\local\programs\python\python36\python.exe
5145 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python.exe
5225 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python.exe
5298 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python.exe
5371 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python.exe
5442 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python.exe
5526 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\VCRUNTIME140.dll
5598 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\VCRUNTIME140.dll
5669 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\VCRUNTIME140.dll
5753 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\VCRUNTIME140.dll
5840 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\VCRUNTIME140.dll
6061 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6134 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6208 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6282 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6354 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6430 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6503 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6576 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6651 WARNING: lib not found: api-ms-win-crt-locale-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6725 WARNING: lib not found: api-ms-win-crt-process-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6798 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6879 WARNING: lib not found: api-ms-win-crt-filesystem-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\python36.dll
6882 INFO: Caching module hooks...
6892 INFO: Analyzing C:\Users\conne\Desktop\python meterpreter\normal.py
6898 INFO: Loading module hooks...
6899 INFO: Loading module hook "hook-encodings.py"...
7055 INFO: Loading module hook "hook-pydoc.py"...
7057 INFO: Loading module hook "hook-xml.py"...
7351 INFO: Looking for ctypes DLLs
7351 INFO: Analyzing run-time hooks ...
7360 INFO: Looking for dynamic libraries
7439 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
7515 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
7589 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
7660 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
7731 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
7813 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
7895 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
7968 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
8051 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
8133 WARNING: lib not found: api-ms-win-crt-filesystem-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_ssl.pyd
8213 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\unicodedata.pyd
8286 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\unicodedata.pyd
8361 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\unicodedata.pyd
8440 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\pyexpat.pyd
8512 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\pyexpat.pyd
8585 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\pyexpat.pyd
8658 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\pyexpat.pyd
8741 WARNING: lib not found: api-ms-win-crt-time-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
8815 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
8887 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
8958 WARNING: lib not found: api-ms-win-crt-conio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
9032 WARNING: lib not found: api-ms-win-crt-environment-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
9116 WARNING: lib not found: api-ms-win-crt-utility-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
9194 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
9271 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
9344 WARNING: lib not found: api-ms-win-crt-convert-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_hashlib.pyd
9428 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_bz2.pyd
9501 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_bz2.pyd
9580 WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_bz2.pyd
9651 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_bz2.pyd
9723 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_bz2.pyd
9801 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_lzma.pyd
9874 WARNING: lib not found: api-ms-win-crt-heap-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_lzma.pyd
9959 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_socket.pyd
10030 WARNING: lib not found: api-ms-win-crt-string-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\_socket.pyd
10115 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\users\conne\appdata\local\programs\python\python36\DLLs\select.pyd
10123 INFO: Looking for eggs
10123 INFO: Using Python library c:\users\conne\appdata\local\programs\python\python36\python36.dll
10124 INFO: Found binding redirects:
[]
10128 INFO: Warnings written to C:\Users\conne\Desktop\python\build\normal\warnnormal.txt
10196 INFO: Graph cross-reference written to C:\Users\conne\Desktop\python\build\normal\xref-normal.html
10212 INFO: checking PYZ
10212 INFO: Building PYZ because out00-PYZ.toc is non existent
10213 INFO: Building PYZ (ZlibArchive) C:\Users\conne\Desktop\python\build\normal\out00-PYZ.pyz
10948 INFO: Building PYZ (ZlibArchive) C:\Users\conne\Desktop\python\build\normal\out00-PYZ.pyz completed successfully.
10958 INFO: checking PKG
10958 INFO: Building PKG because out00-PKG.toc is non existent
10959 INFO: Building PKG (CArchive) out00-PKG.pkg
12884 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
12887 INFO: Bootloader c:\users\conne\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
12887 INFO: checking EXE
12888 INFO: Building EXE because out00-EXE.toc is non existent
12888 INFO: Building EXE from out00-EXE.toc
12916 INFO: Appending archive to EXE C:\Users\conne\Desktop\python meterpreter\dist\normal.exe
13011 INFO: Building EXE from out00-EXE.toc completed successfully.

As you can see the exe is created successfully, but it doesn't work as it should when running it.

EDIT: I ran it with debug enabled and apparently it can't import ctypes, it throws a name error. It only does this when running with pyinstaller, when running as a .py file it works fine.

like image 949
Conner Dassen Avatar asked Feb 09 '18 18:02

Conner Dassen


People also ask

Why is my PyInstaller not working?

The most common reason a PyInstaller package fails is that PyInstaller failed to bundle a required file. Such missing files fall into a few categories: Hidden or missing imports: Sometimes PyInstaller can't detect the import of a package or library, typically because it is imported dynamically.

Does PyInstaller include libraries?

PyInstaller does not include libraries that should exist in any installation of this OS. For example in GNU/Linux, it does not bundle any file from /lib or /usr/lib , assuming these will be found in every system.

What is hidden import in PyInstaller?

--hidden-import. List multiple top-level imports that PyInstaller was unable to detect automatically. This is one way to work around your code using import inside functions and __import__() . You can also use --hidden-import multiple times in the same command.

How do I reduce the size of a python exe?

In order to reduce the size of exe file, we will use the packages that are bound to or installed by PIP instead of Conda. So, the trick is uninstall Conda packages and reinstall them again using pip in a new environment where is clean and fresh.

How do I solve the pyinstaller warning not found error?

Follow the next steps to solve the "PyInstaller WARNING:lib not found:api-ms-win-crt SOLUTION" problem: run the following command line in command prompt or windows power-shell. pyinstaller --windowed --paths C:\Windows\System32\downlevel application_name.py. Additional information can be found here at the MS website.

Why can't I find Windows DLLs in pyinstaller?

When there is a whole slew of WARNINGS coming from pyinstaller about not being able to locate Windows DLLs, you might check to see if they're in one of the two following locations: You can add one or both to the PATH variable, like so and those warnings should disappear:

Why can’t I find a dynamic library in pyinstaller?

Some Python installations do not include a dynamic Python library by default (a static-linked one may be present but cannot be used). You may need to install a development package of some kind. Or, the library may exist but is not in a folder where PyInstaller is searching.

How do I check which modules are installed by pyinstaller?

On each run PyInstaller writes a cross-referencing file about dependencies into the build folder: build/name/xref-name.html in the work-path= directory is an HTML file that lists the full contents of the import graph, showing which modules are imported by which ones. You can open it in any web browser.


1 Answers

I found the DLL's in system32/downlevel and syswow64/downlevel and copied all of them to the respective parent folders (system32 and syswow64). Something that Ritesh Singh's command will do. Try a restart after copying if it still does not work.

EDIT: As mentioned in comments, using set PATH=%PATH%;C:\Windows\System32\downlevel; before using pyinstaller or adding the downlevel folders to path in env variables might be a better idea.(not tested)

like image 160
SajanGohil Avatar answered Oct 13 '22 18:10

SajanGohil