i coded a python script in pycharm as "probe.py" and later built the executable(.exe) file out of it using the mentioned code in setup.py file but the exe file thus created shows error on opening as
import error mising required dependency['numpy'] even when it is present in my project.
error image
import sys
from cx_Freeze import setup,Executable
include_files = ['autorun.inf']
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(name="Probe",version="0.1",description="fun",
options={'build_exe':{'include_files': include_files}},
executables=[Executable("probe.py",base=base)])
`
from cx_Freeze import setup, Executable
base = None
if sys.platform == "win32":
base = "Win32GUI"
build_exe_options = {"packages": ["numpy"],
include_files = ['autorun.inf']}
setup(
name = "Probe",
version = "0.1",
description = "fun",
options = {"build_exe": build_exe_options},
executables = [Executable("probe.py",base=base)]
)
run this script tell me if there is a problem
According to cx_Freeze documentation, try adding build_exe with a packages key.
Related
I'm recently made this chat app in python3 and I would like to convert my script in an executable, I made some research and I found and chose cx_Freeze because is multi-platform and I'm currently working with windows 10. I made this script to make the conversion but when I run it nothing happens. If someone could help me out here it will be great thanks!!!
import cx_Freeze
import sys
base = None
if sys.platform == 'win32':
base = "Win32GUI"
executables = [cx_Freeze.Executable("/mis programas/chat/aplicacion1.1.py", base=base, icon="/mis programas/iconos/3.png")]
cx_Freeze.setup(
name = "PyChaT",
options = {"build_exe": {"packages":["tkinter"], "include_files":["/mis programas/iconos/3.png"]}},
version = "1",
description = "Source of communication",
executables = executables
)
nothing happend when I double click the test.exe.....
But to start from the beginning, I create a Little python Programm which is in test.py:
test.py:
import tkinter
top = tkinter.Tk()
top.mainloop()`
Then I use cx_Freeze to convert test.py to an exe:
The following lines are in my Setup.py:
import sys
from cx_Freeze import setup, Executable
import os
build_exe_options = {"packages": ["tkinter"], "include_files":[r"C:\\Program
Files\\Python36\\tcl\\tcl8.6",
r"C:\\Program Files\\Python36\\tcl\\tk8.6"]}
os.environ['TCL_LIBRARY'] = "C:\\Program Files\\Python36\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\\Program Files\\Python36\\tcl\\tk8.6"
base = None
if sys.platform == "win32":
base = "Win32GUI" `
setup( name = "stest",
version = "1.0",description = "hello",
options = {"build_exe": build_exe_options},
executables = [Executable("test.py", base='Win32GUI')])`
Then I open a cmd and type in the following " python setup.py build". No erros appears while Building.
But if I click the test.exe nothing happend.
Where is my mistake?
Do NOT install cx_freeze by "pip install cx_freeze", because an old Version will be installed,
instead go to https://pypi.python.org/pypi/cx_Freeze and then download the right version.
Use for example pip install cx_Freeze-6.0b1-cp36-cp36m-win_amd64.whl.
Finally copy the file "tcl86t.dll" and "tk86t.dll" into the build folder
I try to make a msi for my programe with cx_Freeze use python3.5( setup.py bdist_msi ,and get this massege
Screenshot:
Here is my setup.py:
import sys
import os
from cx_Freeze import setup, Executable
build_exe_options = {"optimize": 2,"include_files": ["Frame.py"]}
base = None
if sys.platform == 'win32':base = 'Win32GUI'
os.environ['TCL_LIBRARY'] = r'D:\Python35\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'D:\Python35\tcl\tk8.6'
executables = [Executable(script='Frame.py',base=base,)]
can you help me?
Try removing the extra , after base, in this line:
executables = [Executable(script='Frame.py',base=base,)]
Make it:
executables = [Executable(script='Frame.py',base=base)]
I am trying to create an executable from my Python project using cx_Freeze, but keep running into this error:
Here's my setup.py:
import cx_Freeze
import os, sys
os.environ['TCL_LIBRARY'] = "D:\\Code\\Python\\3.5.2\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "D:\\Code\\Python\\3.5.2\\tcl\\tk8.6"
base = None
if sys.platform == "win32":
base = "Win32GUI"
executables = [cx_Freeze.Executable("Main.pyw", base=base)]
includes = ["tkinter"]
include_files = [r"D:\Code\Python\3.5.2\tcl\DLLs\tcl86t.dll", \
r"D:\Code\Python\3.5.2\tcl\DLLs\tk86t.dll"]
cx_Freeze.setup(
name="Test",
version = "1.0",
options={"Test.exe": {"packages":["pygame", "numpy"], "includes": includes, "include_files": include_files}},
executables = executables)
I tried putting tkinter in the "packages" list, but still get the same error. I also checked other StackOverflow posts and used parts of their setup.py code into mine, but nothing is working. I can't use PyInstaller as it doesn't support pygame and py2exe doesn't support Python 3.5. Any help would be appreciated.
Copy and Paste the files (tcl86t.dll, tk86t.dll) to the exe.win .
It worked for me.
I have a .py file that I am trying to convert into an exe. I have tried numerous tries to build this file using cx_Freeze, but I keep getting the same error every time.
I've heard that it's got something to do with cx_Freeze, so I uninstalled cx_Freeze and reinstalled it using pip install cx_freezexxxx.whl wheel, but that still didn't work. I build my exe by writing python setup.py build in command line. Here's my setup .py code.
import cx_Freeze
import sys
import os
os.environ['TCL_LIBRARY'] = "C:\\Users\\louisa\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\\Users\\louisa\\tcl\\tk8.6"
base = None
if sys.platform == 'win32':
base = "Win32GUI"
executables = [cx_Freeze.Executable("filemakergui.py", base=base, icon="Treetog-I-Documents.ico")]
cx_Freeze.setup(
name = "ALT File Maker",
options = {"build_exe": {"packages":["tkinter"], "include_files":["Treetog-I-Documents.ico", "Hopstarter-Sleek-Xp-Basic-Help.ico", "Custom-Icon-Design-Flatastic-2-Success.ico"]}},
version = "0.01",
description = "ALT File Maker",
executables = executables
)
Is there anything wrong with what I've written in my setup.py file? I've been stuck on this problem for several days now. Any tips on resolving an issue like this?