Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cx_freeze can not import numpy

my main py file is working correctly, but when i froze this with cx_freeze and i try to open, it occurs an error and can not open. it says: enter image description here

and this is my setup.py :

import os
from cx_Freeze import setup, Executable
build_exe_options = {"packages":["lxml","gzip","requests"]}

setup(  name = "name",
        version = "0.1",
        description = "description",
        options = {"build_exe": build_exe_options},
        executables = [Executable("file.py", icon=os.path.join("icon_64x64.ico"), base="Win32GUI")])

..

like image 715
Tony Stark Avatar asked Oct 29 '22 13:10

Tony Stark


2 Answers

This worked for me python 3.6:

build_exe_options = {"packages": ["os", "numpy"], "includes": ["numpy"]}
base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(name="Hello World",
      version="0.1",
      description="My GUI application!",
      options={"build_exe": build_exe_options},
      executables=[Executable("main.py", base=base)])
like image 129
YoloAcc Avatar answered Nov 15 '22 05:11

YoloAcc


This will work :

find "_methods" in site-packages/numpy/core/ (Specific location in my case: C:\ProgramFile\Anaconda3\Lib\site-packages\numpy\core) and copy it to build/exe.win32-2.7/lib/numpy/core/

Run now, it will works.

like image 37
Shalini Baranwal Avatar answered Nov 15 '22 05:11

Shalini Baranwal