Note that there are some explanatory texts on larger screens.

plurals
  1. POrunning a python script as administrator
    text
    copied!<p>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:</p> <pre><code>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, ) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload