brentvollebregt / auto-py-to-exe

Converts .py to .exe using a simple graphical interface
MIT License
3.95k stars 677 forks source link

Admin only GUI appearance #466

Closed San3-Cod3 closed 5 months ago

San3-Cod3 commented 7 months ago

Sorry to be that guy - it's just suddenly auto-py-to-exe / autopytoexe only opens while cmd is run as Administrator now - this wasn't the case for me ever before and I don't know what has changed, as I haven't done anything different; it always worked with a standard cmd window without elevated privileges - even going to its directory and running its binary executable directly, the GUI stays in the background as background task if it isn't run as Administrator; why is this now?

TL;DR Admin and GUI appears No Admin and it stays in the background

Edit: Separate thing based on blog post. Mention of downlevel for .DLL files and them being in that directory, not sure if relevant but also there may be such similar files in CompatTel : C:\Windows\System32\CompatTel -- maybe relevant, maybe not, just thought I'd throw that in here.

Edit2: I just happened to build an exe via Admin cmd and I noticed that a dependency for my script that my application would rely on was not included by auto-py-to-exe. So the application just wouldn't work and crashed...

%USERPROFILE%\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\tkinterDnD

Is it possible Lib\site-packages are ignored when building the exe?

How would I include this directory, as it is how my drag and drop feature works for my application. Would I do one folder mode instead of one file and just bundle it in? I am not actually sure...

Traceback (most recent call last): File "my.py", line 49, in File "tkinterDnD\tk.py", line 36, in init File "tkinterDnD\tk.py", line 28, in _init_tkdnd _tkinter.TclError: can't find package tkdnd [428] Failed to execute script 'my' due to unhandled exception!

Edit3: Okay, One Directory mode worked but that sucks, lol - how can I have it find and use tkinterDnD located in site-packages as I ideally need One File mode?

Edit4: It seems I can still add the folder in even with One File mode; my bad...

Edit5: Something to mention though is:

If I try to use auto-py-to-exe again by clearing the output text on GUI screen, just after having successfully used it to make an executable, I get the following error:

" ValueError: Target module "setuptools.extern.six.moves.urllib" already imported as "AliasNode('setuptools.extern.six.moves.urllib', "'pkg_resources._vendor.six.moves'")".

Project output will not be moved to output folder

Complete. "

And, when I get this error or similar worded, I always have to open up a new instance of auto-py-to-exe and start again under Admin only as it currently is, as only working this way.

Edit6: This is what I am doing for now, but I still have to accept UAC (User Account Control) prompt and agree to open the exe as Admin - but it's a solution for now that's a bit less annoying than before, where I would have to go to the exe location and right-click to run as Administrator. It involves creating shortcut of the EXEs where you need them, and then right-clicking the shortcut and going to Properties, Shortcut TAB, Advanced..., and finally selecting the checkbox to run as Administrator and hitting: OK, Apply, OK. And then from there, launching them via double-click would have 'em automatically open up as Admin with the caveat of a UAC pop-up. It's still better than running a cmd window as Admin and then typing the names in, but not by a lot as UAC is still an annoyance. auto-py-to-exe should not need Admin privileges in general. http://puu.sh/K2s5J/06c62c9485.png

github-actions[bot] commented 7 months ago

👋 Hi, just a reminder that if you haven't read the help post yet, give it a read to see if your issue is covered in it and make sure to follow the debugging section.

Also please note, as stated in the README, if your issue is only associated with your application and not auto-py-to-exe itself, please do not create an issue in this repository - instead, comment on the help post, video or create a new discussion.

brentvollebregt commented 7 months ago

When you say "stays in the background as background task", are you meaning the UI doesn't open at all and just the Python process is running, or do you mean the UI opens in the background (unfocused) and then you need to click on the taskbar icon to focus the window?

San3-Cod3 commented 7 months ago

Sorry for not making that even more clearer:

So, I'll launch auto-py-to-exe for example without Administrator privileges - whether by launching its exe directly or using CLI, and a CMD Command Prompt / Terminal / Console Window appears for it, a blank empty cmd window like so: http://puu.sh/K2wxw/faa7e66968.png -- this would appear using an Admin cmd too, and this is normal behaviour and will show up on-screen and have a spot on the TaskBar in both scenarios.

And, at the same time, the Python Interpreter executable launches in the background as it does usually, along with the executable for auto-py-to-exe, here: http://puu.sh/K2wwT/28cd3b11b8.png -- both running in the background - BUT, the Graphical User Interface for auto-py-to-exe does not appear at all, as in the UI does not launch, it is not in the TaskBar; not on-screen -- there is no interface to interact with; nothing can be brought to the Foreground, it exists simply as a Background Task in this: non-Administrator state. Something relating to privileges or something is preventing the GUI from appearing; at least for me.

Now, when auto-py-to-exe is run as an Administrator through cmd or its exe, the GUI will appear as normal on-screen: http://puu.sh/K2wEd/9608826cff.png -- with its usual place on the TaskBar. And its background process then appearing like this: http://puu.sh/K2wBD/739926c4a8.png

Do note slight change in image for its background task, it differs from when it's running normally and on-screen, versus when it won't appear - yellow Python script icon ( no GUI ) vs. generic green and white application icon ( visible GUI ).

brentvollebregt commented 7 months ago

I noticed the executable running was auto-py-to-exe.exe - this project does not supply a file named this.

You can find the proper installation and usage in the README.

San3-Cod3 commented 7 months ago

I'm confused to be honest.

Either way, this isn't the only executable - there are two:

http://puu.sh/K2x5C/bfe2f136ca.png

There's these folders as well:

http://puu.sh/K2x6p/47838c3fd7.png

Located in:

%USERPROFILE%\AppData\Local\Programs\Python\Python36-32\Lib\site-packages

http://puu.sh/K2x7e/1955309e2b.png

http://puu.sh/K2x7C/44639119de.png

You're saying you don't recognise these?

http://puu.sh/K2x89/08617e8782.png

http://puu.sh/K2x8k/4d896a1582.png

brentvollebregt commented 7 months ago

My bad, those are the executables Python makes for entry_points in setup.py - I had thought this was a custom .exe.

When running auto-py-to-exe from a non-admin terminal (a case where you say the UI doesn't open), is there any output in the terminal you ran the command from?

Also is it opening another console window when running auto-py-to-exe from a terminal? That's a bit odd 🤔

San3-Cod3 commented 7 months ago

So, when I use a non-Administrative Command Prompt and type: auto-py-to-exe, just like that, in the background I get this as I linked previously before: https://puu.sh/K2wwT/28cd3b11b8.png -- the cmd window I used to enter that command into then goes into wait mode with the blinking white line (Terminal Cursor) on the upper left-hand side, (no text in cmd, other than what was user typed), and then you get the typical slight screen flash as if a program or application is loading and preparing to launch, but then the GUI does not actually appear like normal behaviour, not in the TaskBar and nowhere to be seen, with no way for it to be interacted with - no way of having it come to the Foreground, and with an Admin Console like I mentioned before, it launches just fine and would appear in the background as this: http://puu.sh/K2xfH/ff995d5855.png. It wasn't always like this though, as in the past it would work normally without needing any elevated Admin privileges. Odd indeed.

The way I can describe this after having thought about it some more is, ironically, it's like its stuck in headless mode without Admin privileges, I.E like when you make an exe with the program itself and choose to "hide the console" xD -- but the GUI is hidden in this regard, and then with Admin rights it's like it appears normally like making things GUI Window Based.

But other than what I have described thus far - I don't have any more information I can provide on this issue; unless you can think of something.

Any idea or suggestion? @brentvollebregt

Able to reproduce?

brentvollebregt commented 7 months ago

Sorry for the late reply - have been busy.

I noticed you said, "get the typical slight screen flash as if a program or application is loading and preparing to launch" when running from cmd without admin - sounds like Chrome tried to open the application but something happened.

It's interesting you say this was working before and now you have this issue - the last UI change that impacted the UI in any way was almost a year ago.

If you try using auto-py-to-exe --no-chrome, do you still have this happen?

github-actions[bot] commented 5 months ago

This issue is stale because it has been open for 60 days with no activity. Remove stale label or comment on this issue or it will be closed in 5 days.

github-actions[bot] commented 5 months ago

Closing issue due to no activity in more than 60 days.

San3-Cod3 commented 1 week ago

Sorry I never got back for a long time - I did have a long and detailed reply that I was writing on mobile during that time and one slight slip navigated away from the page, thus losing my entire extensive reply; and I had no such energy or desire to re-write any of it from scratch again, so just left it...

But despite that, this was a very much appreciated solution either way: auto-py-to-exe --no-chrome - so thank you for that @brentvollebregt

Using: auto-py-to-exe --no-chrome essentially launched Firefox which I use as my deafult browser these days, and there are no such issues with this method. So, I'll be using that command to launch auto-py-to-exe / autopytoexe from now on.

And thank you so very much for your contributions and for providing this utterly life-saving piece of GUI front-end software. I use it often.