cx_freeze creates exe that requests admin rights - python

I am using cx_freeze 4.3.3 for python 3.3. It creates an exe file, but out of sudden, the created file asks for admin rights. This never happened before.
And I need it to create exe files that do not request admin rights.
Is there a reason why it is doing that? Or is there a way to set it up so the file won't request admin rights?
Here's the setup.py code:
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(
name = "QueueUpdate",
version = "1.6",
description = "Tracker for CRAP. Internally, our hamsters work very\
hard to keep track of your time. Be grateful and find a way to feed them.",
executables = [Executable("queueupdate2.py", base = base)]
)
Thank you

Related

Packaging a PyQt5 app for Mac OS

I'm running into a problem trying to package a PyQt program as a Mac OS application.
I can create the app using cx_Freeze, but when I open the app it quits unexpectedly. In the console it shows the error that there are two versions Qt installed on the computer and it can't decide which one to use. One version is in the app I just made and the other is in /usr/local/Cellar/qt5/...
How do I get around this? The script works totally fine not packaged as an app.
EDIT:
Adding the errors and setup.py
Console readout:
objc[56464]: Class NotificationReceiver is implemented in both /path/to/the.app/Contents/MacOS/QtWidgets and /usr/local/Cellar/qt5/5.5.1_2/lib/QtWidgets.framework/Versions/5/QtWidgets. One of the two will be used. Which one is undefined.
objc[56464]: Class QCocoaPageLayoutDelegate is implemented in both /path/to/the.app/Contents/MacOS/QtPrintSupport and /usr/local/Cellar/qt5/5.5.1_2/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport. One of the two will be used. Which one is undefined.
objc[56464]: Class QCocoaPrintPanelDelegate is implemented in both /path/to/the.app/Contents/MacOS/QtPrintSupport and /usr/local/Cellar/qt5/5.5.1_2/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport. One of the two will be used. Which one is undefined.
setup.py:
from cx_Freeze import setup, Executable
import sys
# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages=[], excludes=[])
base = 'Win32GUI' if sys.platform == 'win32' else None
executables = [
Executable('qt_test.py', base=base)
]
setup(
name='SpamEggs',
version='0.1',
description='The Description',
options=dict(build_exe=buildOptions),
executables=executables
)

Python cx_freeze setup script not working

I have a python script that I'd like to freeze. I made the cx_freeze script, and ran it. The .exe works well, but in the frozen script I open a .html file. When the file opens the webbrowser gives me the error "File not found: Firefox cannot find the file at /c:/blah/blah/blah/somefile.html"
As I understand it, this is because cx_freeze is confusing my OS between linux and Windows. However, I'm not sure this is it because I have the code
if sys.platform == "win32":
base = "Win32GUI"
In my setup file. Does anyone know what's going on?
My entire setup file is
import sys
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]}
# 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 = "someexe",
version = "0.1",
description = "someexe description",
options = {"build_exe": build_exe_options},
executables = [Executable("someexe.py", base=base)])
copied from the cx_freeze distutils page and edited to fit my needs.
Instead of using os.chdir('C:/path/to/dir'), you should be using os.chdir('C:\path\to\dir'). It's an error in your script, not your cx_freeze setup file.

Dependancy with egg and building app with CX_freeze not being packaged

I have a setup.py script that builds an .app file on OS X, however I need to include pyusb which was installed with pip. It's located /Library/Python/2.7/site-packagespyusb-1.0.0a3-py2.7.egg I am able to use it within my application however when I try to build and run it it doesn't include this dependancy. My setup script looks like:
application_title = "software" #what you want to application to be called
main_python_file = "./src/main.py" #the name of the python file you use to run the program
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == "win32":
base = "Win32GUI"
includes = ["atexit","re"]
setup(
name = application_title,
version = "0.1",
description = "Description",
options = {"build_exe" : {"includes" : includes }},
executables = [Executable(main_python_file, base = base)])
I've seen an answer of adding pkg_resources to my includes but from what I have tried this has had no success. So what do I need to include pyusb in my application file.

running a python script as administrator

i'm writing an installer using py2exe which needs to run in admin to have permission to perform various file operations. i've modified some sample code from the user_access_controls directory that comes with py2exe to create the setup file. creating/running the generated exe works fine when i run it on my own computer. however, when i try to run the exe on a computer that doesn't have python installed, i get an error saying that the import modules (shutil and os in this case) do not exist. it was my impression that py2exe automatically wraps all the file dependencies into the exe but i guess that this is not the case. py2exe does generate a zip file called library that contains all the python modules but apparently they are not used by the generated exe. basically my question is how do i get the imports to be included in the exe generated by py2exe. perhaps modification need to be made to my setup.py file - the code for this is as follows:
from distutils.core import setup
import py2exe
# The targets to build
# create a target that says nothing about UAC - On Python 2.6+, this
# should be identical to "asInvoker" below. However, for 2.5 and
# earlier it will force the app into compatibility mode (as no
# manifest will exist at all in the target.)
t1 = dict(script="findpath.py",
dest_base="findpath",
uac_info="requireAdministrator")
console = [t1]
# hack to make windows copies of them all too, but
# with '_w' on the tail of the executable.
windows = [{'script': "findpath.py",
'uac_info': "requireAdministrator",
},]
setup(
version = "0.5.0",
description = "py2exe user-access-control",
name = "py2exe samples",
# targets to build
windows = windows,
console = console,
)
Try to set options={'py2exe': {'bundle_files': 1}}, and zipfile = None in setup section. Python will make single .exe file without dependencies. Example:
from distutils.core import setup
import py2exe
setup(
console=['watt.py'],
options={'py2exe': {'bundle_files': 1}},
zipfile = None
)
I rewrite your setup script for you. This will work
from distutils.core import setup
import py2exe
# The targets to build
# create a target that says nothing about UAC - On Python 2.6+, this
# should be identical to "asInvoker" below. However, for 2.5 and
# earlier it will force the app into compatibility mode (as no
# manifest will exist at all in the target.)
t1 = dict(script="findpath.py",
dest_base="findpath",
uac_info="requireAdministrator")
console = [t1]
# hack to make windows copies of them all too, but
# with '_w' on the tail of the executable.
windows = [{'script': "findpath.py",
'uac_info': "requireAdministrator",
},]
setup(
version = "0.5.0",
description = "py2exe user-access-control",
name = "py2exe samples",
# targets to build
windows = windows,
console = console,
#the options is what you fail to include it will instruct py2exe to include these modules explicitly
options={"py2exe":
{"includes": ["sip","os","shutil"]}
}
)

QGraphicsPixmapItem won't appear after using cx_freeze

I am having trouble understanding why my QGraphicsPixmapItem is not showing up after I build the application using cx_freeze. Are there any known issues with that class and cx_freeze or am I missing some settings with cx_freeze? Here is the part that is creating and displaying the QGraphicsPixmapItem and after that is my setup.py for cx_freeze:
def partNo_changed(self):
self.scene.removeItem(self.previewItem)
partNumber = self.ui.partNo.text()
fileLocation = 'drawings\\FULL\\%s.svg' % partNumber
print(fileLocation)
pixmap = QtGui.QPixmap(fileLocation)
self.previewItem = QtGui.QGraphicsPixmapItem(pixmap)
self.previewItem.setPos(0, 0)
self.scene.addItem(self.previewItem)
self.ui.svgPreview.centerOn(self.previewItem)
and here is the setup.py script:
from cx_Freeze import setup, Executable
files = ['drawings\\FULL']
setup(
name = 'DBManager',
version = '1.0',
description = 'Makes and maintains the .csv database files.',
author = 'Brock Seabaugh',
options = {'build_exe': {'include_files':files, 'bin_path_includes':files}},
executables = [Executable('dbManager_publicDB.py')])
Everything else works in the program, this is the only thing that is not working(it works if I just run the .py script, but not when I run the exe). I get no errors when I build or run the exe. If someone could help with this that would be great. I am using Python v3.1 and cx_freeze v4.2.3 and PyQt v4.
So I found the answer to my question. Apparently the problem wasn't with the QGraphicsPixmapItem class, it was with the QtSvg portion of the application. Which threw me off because cx_freeze's output showed that the QtSvg Module was included when creating the executable, but that is not all that is needed by the program. It needs the qt.conf file also with it. All I had to do to fix the problem was go find the qt.conf file at '...\Python31\Lib\site-packages\PyQt4\bin\qt.conf' and copy that file to the directory where your application's executable is at and voilĂ , it works!

Categories