I have designed a small application in Python under Windows, that uses opencv. I amm trying to create an executable so that anyone can install and use it, without having to install python/opencv/numpy . . .
I tried to use py2exe for this. It actually creates a .exe file, even though I have a warning during the build :
*** copy dlls ***
copying C:\Windows\system32\MSVFW32.dll ->
...
The following modules appear to be missing
['cv2.cv']
When I try to run the .exe file using the command line, I see the message :
ImportError: numpy.core.multiarray failed to import
My setup.py file is pretty simple :
# creating executable here
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 1}},
console=['facemovie.py'],
zipfile = None,
)
Any idea how I can solve this? This is the very first time I want to deploy, and I may be missing something.
Thanks !
opencv is supported as of https://github.com/pyinstaller/pyinstaller/pull/36. You'll need to use the current development version, of course.
In order to more easily run Python scripts on Windows machines, you can convert Python to .exe files using either cx_freeze or PyInstaller.
The one executable file contains an embedded archive of all the Python modules used by your script, as well as compressed copies of any non-Python support files (e.g. . so files). The bootloader uncompresses the support files and writes copies into the the temporary folder. This can take a little time.
I would also recommend using PyInstaller. I used it for a project of mine that referenced both pycrypto and twisted and it worked like a charm.
According to this post, py2exe is not detecting that this module is needed inside the ZIP archive. I don't know the right syntax so you'll have to check the docs, but you could try:
python setup.py py2exe -p cv2
Or you could try to tweak setup.py
to the following:
options = {'py2exe': {'bundle_files': 1, 'packages': 'cv2' } },
And if you are willing to try something completely different, take a look at bbfreeze:
create standalone executables from python scripts
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With