Tag Archives: Pyinstaller

Pyinstaller Package Error: ImportError: OpenCV loader: missing configuration file: [‘config.py‘]

When writing Python today, I referenced CV2 when packaging with pyinstaller, and this error occurred:

ImportError: OpenCV loader: missing configuration file: ['config.py']. Check OpenCV installation.

 

Create a new Python file and get the path of OpenCV:

import cv2
print(cv2.__file__) 

Here I get: C:\Anaconda3\lib\site-packages\cv2\__init__.py

After you reuse pyinstaller for packaging, add the paths parameter:

pyinstaller main.py -F --paths="C:\Anaconda3\lib\site-packages\cv2"

No error reported, successful operation!

The pyinstaller packing belt icon reports an error

The phenomenon is that it can be packaged into exe through pyinstaller – F — icon = logo.ico dddd.py. When the — icon parameter is not added, it can be packaged successfully, and the error “struct. Error: unpack requires a string argument of length 16” is reported after adding. Baidu gets the answer to the problem of the size of the icon file. The original size is 16×16. After changing to 128×128, it is packaged successfully

pyinstaller WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency

“How do you find yourself?” >>

https://github.com/pyinstaller/pyinstaller/issues/2216

Downloads

Visual C++ Redistributable for Visual Studio 2015

Visual C++ libraries and the Universal CRT

added polygon variable PATH

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

Pyinstaller publishes exe and pops up failed to execute script main

Detailed map traversal, teach you to master the complex gremlin query debugging method>>>

1. Press Alt + F12 in pychar to open the terminal dialog box

1.1 my project files are placed in the wxPython directory, D: learn, weather index insurance, wxPython > pyinstaller -F -w teaindex_ main.py

1.2 after running, the dist folder and build folder will be generated in the directory D: learn, weather index insurance and wxPython. My exe program is in the dist folder. Double click the EXE to pop up:

1.3 in the terminal dialog box again, run D: learn, weather index insurance, wxPython > pyinstaller -F -c teaindex_ Main.py, run exe, you can see the problem, the lack of module typedefs

You should use: pyinstaller – F – C demo.py. After packaging, click exe to execute the file. If an error is reported, it will be displayed on the console. This is, to prepare for the screenshot, because the console error is a flash

1.4 refer to online solutions

Change the packing code to:

D:\learn\Weather index insurance\wxpython> pyinstaller -F -c teaindex_ main.py –hidden-import sklearn.neighbors.typedefs

The problem is solved! The executable file is generated successfully

1.5 generate the program with icon D: learn, weather index insurance, wxPython > pyinstaller -F -w -i sunny.ico teaindex_ main.py –hidden-import sklearn.neighbors.typedefs

1.6 can find existing pyqt5 plugin directories when packaging. The specific screenshot is as follows

Solution:

Search pyqt5 with everything, find the pyqt5 folder under the path of/library/plugins, and copy the DLL Dynamic Library pyqt5qmlplugin.dll

According to the path of the error prompt, create a new folder one by one, and form the directory C:: (qt5b) QT_ 1524647842210\_ h_ Env library plugins, copy the DLL dynamic library just copied in

1.7 in addition to the above module, no module named ‘sklearn. Utils_ cython_ Blas’, add this module to the end, as shown below

pyinstaller -F -w teaindex_ main.py –hidden-import sklearn.neighbors.typedefs –hidden-import sklearn.utils._ cython_ blas

Pyinstall package py script warning: lib not found and other related issues

Detailed map traversal, teach you to master the complex gremlin query debugging method>>>

Since pyinnstaller was used to package py as an EXE file, xiaocrawler has always encountered problems such as warning: lib not found

Although most of the time, you ignore these warnings like me, the packaged exe can also run. There are a lot of methods on the Internet. Some suggest installing win7, others suggest changing 32-bit Python files, and there are prompts to download 2G related SDKs. In a word, pyinstaler is not friendly enough to the current win10 support! But the cost of these methods on the Internet is too high, so how to use pyinstaler gracefully without full screen warning prompt without changing win10 x64 system and python Version (3.6.4)

After some groping, I finally found a way. Pyinstaller prompts that these DLL files that can’t be found, such as api-ms-win-crt-runtime-l1-1-0.dll, actually exist in win10 system, most of them are in the path of C: (Windows/system32) Downlevel and its upper path of C: (Windows/system32 , as shown in the following figure:

We just need to add these two paths to the user environment variables

After adding environment variables, when pyinstaller packages py files, it will first search these paths, and then it can package successfully PS: remember to log off the system and log in again before it takes effect

Package again, the page is much more refreshing, win10 x64 pro test effective

PS: it should be noted that although our pyinstaller package py file often shows “ success “, when we run the EXE file, we still report an error, such as fail to execute script. The terminal interface often flashes by, and we can’t even see the specific reason with our naked eyes for many times! There is a stupid way to climb – record screen . Recommend an easy to use screen recording software OCAM. The prompt information that seems to flash by the naked eye will be completely recorded by the screen recording software to form an MP4 file. With the help of the pause function of the player, we can locate the error information. Here are some of the errors I encountered during execution:

At this time, the problem is simple. For example, the above two figures indicate that one cannot find the module distuils, and the other indicates that the dependency library xlrd needs to be installed. We can find the distuils folder from the Lib file corresponding to the location of the python file and put it in the folder corresponding to our python (Env), while xlrd can be installed directly with PIP

PS: if you want to package a py file that references the panda library as I do, you should not directly Import panda as PD in the program as far as possible. In this way, the packaged EXE file is very large, and you can refer to any function you use, such as:

from pandas import read_ csv,read_ excel,DataFrame,concat

If you have this kind of trouble when using pyinstaller, please try my method again