When using cx_freeze with my application I get the following error when runnig the executable:
The setup.py file is:
import sys
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {
"includes": ['numpy', 'networkx', 'pandas', 'xlwt', 'matplotlib', 'xlsxwriter', 'numba', 'scipy.sparse.linalg', 'scipy.sparse.csgraph._validation'],
"packages": ['pkg_resources'],
'excludes' : [],
"include_files": [('C:\\Anaconda3\\Lib\\site-packages\\scipy\\special\\_ufuncs.pyd','_ufuncs.pyd'), ('C:\\Anaconda3\Lib\\site-packages\\scipy\\sparse\\linalg\\isolve\\_iterative.pyd', '_iterative.pyd')]}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup( name = "GridCal",
version = "0.1",
description = "GridCal",
options = {"build_exe": build_exe_options},
executables = [Executable("main_gui.py", base=base)])
The scipy.sparse.linalg.isolve._iterative.pyd libary is there, so I don't know what the problem is.
Related
I am trying to make correctly import the function "mmenu" from another module
I got a run time error:
Traceback (most recent call last):
File "path.../venv/src/routes.py", line 4, in <module>
from venv.src.main_menu import mmenu
ModuleNotFoundError: No module named 'venv.src'
after Java this Python is a bit of a mystery to me :)
I have 2 files in the same "src" directory
main_menu.py
def mmenu():
menu = [{"name": "HOME", "url": "home"},
{"name": "fooo", "url": "foo"},
{"name": "bar", "url": "bar"},
{"name": "CONTACT", "url": "contact"}]
return menu
routes.py
from flask import Flask, render_template, request, flash, session, redirect, abort
from jinja2 import Template
from flask.helpers import url_for
from venv.src.main_menu import mmenu
app = Flask(__name__)
menu = mmenu
#app.route("/")
#app.route("/index")
def index():
# return "index"
print("loaded" + url_for('index'))
return render_template('index.html', title="Index page", menu=menu)
# ...
if __name__ == "__main__":
app.run(debug=True)
import was generated by IDE like:
from venv.src.parts.main_menu import mmenu
Your IDE (which IDE?) is likely misconfigured if it generates imports like that.
The venv itself, nor any src directory within them, shouldn't be within import paths.
You never mention you have a parts/ package, but from the import I'll assume you do, and your structure is something like
venv/
src/ # source root
routes.py
parts/ # parts package
__init__.py # (empty) init for parts package
main_menu.py
With this structure, main_menu is importable as parts.main_menu from routes.py assuming you start the program with python routes.py.
If you have __init__.py files in venv/ and/or src/, get rid of them; you don't want those directories to be assumed to be Python packages.
I made a program in Python 3 to make a board of a Bot to Crypto currency. The program works fine without error but with cx_Freeze I have an error on a query with coinmarketcap with the error that the SSL module is missing.
import sys
from cx_Freeze import setup, Executable
import os
import requests.certs
packages = ["tkinter", "requests", "idna", "queue", "coinmarketcap", "requests_cache", "PIL", "urllib3", "OpenSSL", "ssl", "arrow", "tempfile", "json", "locale", "C:\\Users\\cavaud\\Desktop\\botTKinker\\config", "time", "sys", "MySQLdb", "urllib.request"]
includeFile = [requests.certs.where(), "cacert.pem", "ico24x24.ico" , "bas.png", "haut.png", "egal.png", "level.png", "logoBotV2H2.png", "orderNOK.gif", "orderOK.gif", "C:\\Users\\cavaud\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs\\tcl86t.dll", "C:\\Users\\cavaud\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs\\tk86t.dll"]
path = sys.path
os.environ['TCL_LIBRARY'] = "C:\\Users\\cavaud\\AppData\\Local\\Programs\\Python\\Python37-32\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\\Users\\cavaud\\AppData\\Local\\Programs\\Python\\Python37-32\\tcl\\tk8.6"
os.environ['REQUESTS_CA_BUNDLE'] = "cacert.pem"
base = None
if sys.platform == "win32":
base = "Win32GUI"
options = { "path": path,
"includes": includeModule,
"include_files": includeFile,
"packages" : packages,
"silent": False
}
options["include_msvcr"] = True
cible_1 = Executable(
script="botTK.py",
base=base,
icon="ico24x24.ico"
)
setup(
name="BotTK",
version="1.00",
description="BOT TK",
author="moi",
options={"build_exe": options},
executables=[cible_1]
)
Thank you
Try to modify your setup.py script as follows:
includeFile = [(requests.certs.where(), "cacert.pem"), "ico24x24.ico" , "bas.png", "haut.png", "egal.png", "level.png", "logoBotV2H2.png", "orderNOK.gif", "orderOK.gif", "C:\\Users\\cavaud\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs\\tcl86t.dll", "C:\\Users\\cavaud\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs\\tk86t.dll"]
(please note the parentheses around the first two entries!), and
os.environ['REQUESTS_CA_BUNDLE'] = os.path.join(os.getcwd(), "cacert.pem")
See Requests library: missing SSL handshake certificates file after cx_Freeze
I recently used Neopixel's library provided by Adafruit's (here) on a Raspberry Pi 3 with Raspbian Jessie with Pixel.
Adafruit used a Scons script file to manage build:
SConscript File:
Import(['clean_envs'])
tools_env = clean_envs['userspace'].Clone()
# Build Library
lib_srcs = Split('''
mailbox.c
ws2811.c
pwm.c
dma.c
rpihw.c
''')
version_hdr = tools_env.Version('version')
ws2811_lib = tools_env.Library('libws2811', lib_srcs)
tools_env['LIBS'].append(ws2811_lib)
# Shared library (if required)
ws2811_slib = tools_env.SharedLibrary('libws2811', lib_srcs)
# Test Program
srcs = Split('''
main.c
''')
objs = []
for src in srcs:
objs.append(tools_env.Object(src))
test = tools_env.Program('test', objs + tools_env['LIBS'])
Default([test, ws2811_lib])
SConstruct File:
import os
opts = Variables()
opts.Add(BoolVariable('V',
'Verbose build',
False))
platforms = [
[
'userspace', # Target Name
[ 'linux', 'version' ], # Scons tool (linux, avr, etc.)
{ # Special environment setup
'CPPPATH' : [
],
'LINKFLAGS' : [
],
},
],
]
clean_envs = {}
for platform, tool, flags in platforms:
env = Environment(
options = opts,
tools = tool,
toolpath = ['.'],
ENV = {'PATH' : os.environ['PATH']},
LIBS = [],
)
env.MergeFlags(flags)
clean_envs[platform] = env
Help(opts.GenerateHelpText(clean_envs))
Export(['clean_envs'])
SConscript('SConscript');
My problem is that I currently use gcc, to link wiringPi library I'm using "-lwiringPi" option during compiling.
How can I add the link to wiringPi inside my scons script file?
Thank you very much for your help, and have a good day !
Hugo.
I am currently using Python 3.4 on my windows 10 64x and trying to freeze my application using CX_Freeze. Unfortunetly, I get an error message : "Import error : No module named scipy.special._ufuncs_cxx".
Here is my setup.py :
# -*- coding: Latin-1 -*-
import sys
import scipy
from cx_Freeze import setup, Executable
import PyQt4
packages=['PyQt4.QtCore', 'PyQt4.QtGui', 'sys', 'socket', 'pprint', 'pandas', 'datetime', 'json','numpy', 'scipy']
include_files=['C:/Users/sadid/OneDrive/Documents/Visual Studio 2015/Projects/db/img/lib-ico.ico',
'C:/Users/sadid/OneDrive/Documents/Visual Studio 2015/Projects/Lib/db/img']
if sys.platform == 'win32':
base = 'Win32GUI'
exe = Executable(
script='C:/Users/sadid/OneDrive/Documents/Visual Studio 2015/Projects/Lib/Lib/main.py',
initScript = None,
base=base,
targetName='Lib.exe',
copyDependentFiles = True,
compress = True,
icon='C:/Users/sadid/OneDrive/Documents/Visual Studio 2015/Projects/LibAppCustomer/LibAppCustomer/db/img/lib-ico.ico'
)
setup(
name ='LibApplication',
version = '1.0.0',
description = 'Pricing\'s Application',
author = 'DIKSA',
executables = [exe],
options = {
"build.exe": {
"packages": packages,
'include_files': include_files,
'includes' : ['scipy.special._ufuncs_cxx']
}
}
)
Any help please guys thx
This issue is based on how scipy loads itself and there is a plan in place to have cx_Freeze handle these and other such issues -- but it is still in progress. The comments in this issue, however, can help you workaround the issue for now:
https://bitbucket.org/anthony_tuininga/cx_freeze/issues/43/import-errors-when-using-cx_freeze-with
I want to build a standalone binary file for windowz(xp, 7, ...) from my python3(+ PyQt5) script and I inevitably use cx_freeze because other freezing apps do not work with python3 (like py2exe, pyinstaller).
I read the cx_freeze docs and lots of stackoverflow asks ans use this config for setup.py file :
import sys
from cx_Freeze import setup, Executable
path_platforms = ( "C:\Python33\Lib\site-packages\PyQt5\plugins\platforms\qwindows.dll", "platforms\qwindows.dll" )
includes = ["atexit","PyQt5.QtCore","PyQt5.QtGui", "PyQt5.QtWidgets"]
includefiles = [path_platforms]
excludes = [
'_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
'Tkconstants', 'Tkinter'
]
packages = ["os"]
path = []
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {
"includes": includes,
"include_files": includefiles,
"excludes": excludes,
"packages": packages,
"path": path
}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
exe = None
if sys.platform == "win32":
exe = Executable(
script="D:\\imi\\aptanaWorKPCworkspace\\azhtel\\tel.py",
initScript = None,
base="Win32GUI",
targetDir = r"dist",
targetName="tel.exe",
compress = True,
copyDependentFiles = True,
appendScriptToExe = False,
appendScriptToLibrary = False,
icon = None
)
setup(
name = "telll",
version = "0.1",
author = 'me',
description = "My GUI application!",
options = {"build_exe": build_exe_options},
executables = [exe]
)
run with:
python D:\imi\aptanaWorKPCworkspace\azhtel\setup.py build
This is my library that I used:
from PyQt5 import QtGui, QtCore, QtWidgets
import sys
from telGui import Ui_MainWindow
import mysql
import mysql.connector
from mysql.connector import errorcode
and this is my files in workspace:
But this error happened (or another kind of errors).
Why this happened and what config for setup.py is good for pyqt5 app ??
Thanks.
Python3.3, PyQt5, Mysqlconnector.
I solved this problem with find another directory near the dist directory called build and all library files are in there, i delete targetDir = r"dist" part of setup.py and everythings is alright !
Try pyinstaller. It's much better than cxfreeze.