OpenCV with standalone python executable (py2exe/pyinstaller)

后端 未结 2 1171
盖世英雄少女心
盖世英雄少女心 2021-01-28 11:29

I have a python program that uses OpenCV to get frames from a video file for processing. I then create a standalone executable using py2exe (also tried pyinstaller and got same

相关标签:
2条回答
  • 2021-01-28 12:02

    Try using pyinstaller, download it using pip :

    pip install pyinstaller
    

    if you don't know how to install pip , try downloading python 2.7.9 or above, which has inbuilt pip, but don forget to add python path to environment varibles, this procedure is mentioned in this post:

    How to run Pip commands from CMD

    After installing pyinstaller, select the main file of your project and run this command

    pyinstaller yourprogram.py
    

    it will create folder with application file naming your file name, and finally make sure that numpy and opencv are in lib->site-packages folder of your python27 in your C Folder while running that command

    Hope it Helps!

    0 讨论(0)
  • 2021-01-28 12:16

    I guess I will go ahead and post an answer for this, but solution was provided by @otterb in the comments to the question. I am pasting the text here:

    "py2exe is not perfect so will often miss some libraries or dll, pyd etc needed. Most likely you are missing opencv_highgui249.dl‌​l and opencv_ffmpeg249.dll etc. I would use py2exe with no single executable option enabled. And, start manually copying files that might be needed for your app. After identifying them, modify setup.py for py2exe to include them automatically."

    I will note however that I use pyinstaller rather than py2exe, since I get fewer problems while building. I still have to manually copy the opencv dll files though.On Windows 7 they are located here: "C:\Python27\DLLs" and they need to be copied into the distribution folder so that they are on the same path as the other dll files that go with the distribution.

    0 讨论(0)
提交回复
热议问题