error in running exe file after changing .py to .exe I have changed my python code to an .exe file using pyinstaller and anaconda. In my python script (&quot;untitled.py&quot;) I import opencv which I have already installed from source using cmake. After creating exe file I run untitled.exe in cmd windows. However, I get the following error:

File &quot;PyInstaller\loader\pyimod03_importers.py&quot;, line 531, in exec_module
File &quot;cv2_init_.py&quot;, line 96, in 
File &quot;cv2_init_.py&quot;, line 58, in bootstrap
File &quot;cv2_init_.py&quot;, line 56, in load_first_config
ImportError: OpenCV loader: missing configuration file: ['config.py']. Check OpenCV installation.

There is config.py in OpenCV folder, but it cannot be found. I tried this:
pyinstaller -F  --hidden-import ‘OpenCV’ untitled.py

But still does not work. I wanted to ask how I can solve this issue?
A quick google search of the error message reveals two issues describing the issue and potential solutions.
One of the issues is in the pyinstaller repo, and suggests adding the cv2 path to the pyinstaller invocation:
pyinstaller --onefile sample.py --paths &quot;/root/opencv-4.3.0/release/lib/python3/cv2&quot;

You can get the actual path by running a simple python program:
import cv2
print(cv2.__file__)

The other issue is in the opencv repo and may apply especially if you compiled opencv yourself.
UPDATE: with respect to the error ImportError: DLL load failed while importing cv2, according to the FAQ, you should install the Visual Studio C++ redistributable