cx_Freeze - opencv compatibility

我们两清 提交于 2019-12-24 02:26:22

问题


I get a numpy.core.multiarray failed to import error whenever I try to build an exe file using cx_Freeze.

My system uses the following versions:

python 3.6.0

opencv 3.3.0

numpy 1.13.1

cx_Freeze 5.0

The code is:

import cv2
i=333
print(i)

It runs fine (i.e. builds a good exe file) only if I remove the import cv2 line.

Is there any incompatibility between the four modules I listed?


回答1:


I managed to make this work only after I uninstalled cx_Freeze and installed Pyinstaller instead. It works like a charm.




回答2:


If this can help you, I managed to make a working example under Linux using SimpleCV with the following configuration:

python 2.7.12
SimpleCV 1.3
numpy 1.11.0
cx_Freeze 5.1.1

The example code cv2_example.py is:

import encodings
import cv2
print cv2.__version__
i = 333
print i

The setup script setup.py is:

from cx_Freeze import setup, Executable

build_exe_options = {'packages': ['numpy']}

exe = Executable(script='cv2_example.py', base=None)

setup(name='cv2_example',
      version='1.0',
      executables=[exe],
      options={'build_exe': build_exe_options})

I guess this example could work also for your configuration with python 3.6.0 and numpy 1.11.0 provided you upgrade cx_Freeze to version 5.1.1.



来源:https://stackoverflow.com/questions/47359439/cx-freeze-opencv-compatibility

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!