#๐Ÿ”’ win32gui not installing

171 messages ยท Page 1 of 1 (latest)

timber pawnBOT
#

@native pond

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

native pond
thorn sand
#

run pip install pywin32

#

that'll give you pywin32gui

native pond
thorn sand
#
C:\Users\Taylon>py -m pip install win32gui --verbose
#

you ran win32gui, not pywin32

native pond
# thorn sand ``` C:\Users\Taylon>py -m pip install win32gui --verbose ```

C:\Users\Taylon>py -m pip install pywin32
Collecting pywin32
Using cached pywin32-308-cp313-cp313-win_amd64.whl.metadata (8.3 kB)
Using cached pywin32-308-cp313-cp313-win_amd64.whl (6.5 MB)
Installing collected packages: pywin32
Successfully installed pywin32-308

Python Script Running
C:\Users\Taylon>
Traceback (most recent call last):
File "C:\Users\Taylon\Downloads\main.py", line 3, in <module>
import win32gui
ModuleNotFoundError: No module named 'win32gui'

#

@thorn sand

thorn sand
native pond
#

idle

#

@thorn sand

thorn sand
#

Okay, and what happens if you use from win32 import win32gui

native pond
#

isnt there a way to put the modules in a folder?

#

and then share that

#

@thorn sand

thorn sand
#

You can use pyinstaller to bundle it yeah

native pond
thorn sand
#

Then run pyinstaller script.py

native pond
# thorn sand Then run `pyinstaller script.py`

PS C:\Users\littl\Downloads> pyinstaller main.py
pyinstaller : The term 'pyinstaller' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1

  • pyinstaller main.py
  •   + CategoryInfo          : ObjectNotFound: (pyinstaller:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
thorn sand
#

Try py -m pyinstaller

native pond
#

i just downloaded it

thorn sand
#

If you run py -m pip install pyinstaller what's the output?

native pond
# thorn sand If you run `py -m pip install pyinstaller` what's the output?
PS C:\Users\littl\Downloads> py -m pip install pyinstaller
Requirement already satisfied: pyinstaller in c:\users\littl\appdata\local\programs\python\python311\lib\site-packages (6.11.1)
Requirement already satisfied: setuptools>=42.0.0 in c:\users\littl\appdata\local\programs\python\python311\lib\site-packages (from pyinstaller) (75.3.0)
Requirement already satisfied: altgraph in c:\users\littl\appdata\local\programs\python\python311\lib\site-packages (from pyinstaller) (0.17.4)
Requirement already satisfied: pyinstaller-hooks-contrib>=2024.9 in c:\users\littl\appdata\local\programs\python\python311\lib\site-packages (from pyinstaller) (2024.9)
Requirement already satisfied: packaging>=22.0 in c:\users\littl\appdata\local\programs\python\python311\lib\site-packages (from pyinstaller) (24.1)
Requirement already satisfied: pefile!=2024.8.26,>=2022.5.30 in c:\users\littl\appdata\local\programs\python\python311\lib\site-packages (from pyinstaller) (2023.2.7)
Requirement already satisfied: pywin32-ctypes>=0.2.1 in c:\users\littl\appdata\local\programs\python\python311\lib\site-packages (from pyinstaller) (0.2.3)```
thorn sand
#

Huh okay, looks like a PATH error

native pond
#

i always have to do py -m

thorn sand
#

Ah, it is a PATH error

#

!path

timber pawnBOT
#
Did you mean...

ยป pathlib
ยป relative-path
ยป windows-path

thorn sand
#

!windows-path

#

Do you know how to add folders to your PATH?

native pond
thorn sand
thorn sand
#

One after that

#

The comprehensive one with screenshots

native pond
#

okasy

native pond
#

dw i got it

#

i just do windows + r

thorn sand
#

right

native pond
#

%app-data%#

#

@thorn sand

#

i got two

thorn sand
#

3.11

native pond
thorn sand
#

Click System

native pond
thorn sand
#

In the windows search bar type "edit environment" and click the option that says "edit environment options"

thorn sand
#

Environment variables

native pond
#

now back to cmd stuff

thorn sand
#

Awesome

#

Open up a new cmd window

#

Now pip should work

native pond
thorn sand
#

Try pyinstaller now

native pond
#

after its done

#

do i just send him the file

thorn sand
#

yep

native pond
#

and it all works

thorn sand
#

It'll give an executable

native pond
#

okasy

thorn sand
#

With the modules, interpreter and script bundles

#

Windows defender may flag it, that's a false positive

native pond
#

can i move the exe location?

#

as my script wont work now

#

as i use file locations#

thorn sand
#

Yep

native pond
#

and now the file isnt in the same foler

native pond
#

the exe just closes

thorn sand
#

I'd use the --onefile option

native pond
thorn sand
#

pyinstaller --onefile script.py

native pond
#

okay ill redo

native pond
#

now

#

i have a disk and a build

#

do i ned both of them folders?

thorn sand
#

you don't need any folders, just the .exe made with onefile

native pond
#

yo @thorn sand so in the file i find a json file inside the folder

#

but now it doesnt work

#

how do i fix?

#

self.config_path = os.path.join(os.path.dirname(__file__), "config.json")

thorn sand
#

Hmmm

#

What's the error

#

If you run the exe from a cmd prompt it'll tell you

native pond
#

it closes to fast

#

but it says file not found

#

its looking in some temp folder

#

in app data

thorn sand
#

Run the exe from a command primpt

native pond
thorn sand
#

In the directory that the exe is in

#

Type file.exe

#

Where it's the name of the exe

native pond
# thorn sand Where it's the name of the exe

main.exe : The term 'main.exe' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1

  • main.exe
  •   + CategoryInfo          : ObjectNotFound: (main.exe:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    
    

Suggestion [3,General]: The command main.exe was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\main.exe". See "get-help about_Command_Precedence" for more details.

thorn sand
#

Type .\main.exe

native pond
# thorn sand Type `.\main.exe`
Traceback (most recent call last):
  File "main.py", line 22, in load_config
    raise FileNotFoundError(f"Configuration file not found: {self.config_path}")
FileNotFoundError: Configuration file not found: C:\Users\littl\AppData\Local\Temp\_MEI101122\config.json
[PYI-10492:ERROR] Failed to execute script 'main' due to unhandled exception!```
thorn sand
#

right ok

native pond
thorn sand
#

yes, bare with

#

Okay don't use __file__

#

Just do self.config_path = "config.json"

native pond
thorn sand
#

aye

native pond
#

when you say do "json"

#

or whatever

#

what if there is a folder

#

bc i have two

#

and one is inside a folder

thorn sand
#

Well you'd put the folder name there

native pond
#

File not found: folder\usernames.txt

thorn sand
#

So if it was in a folder called "ABC" you'd put

#

abc\config.json

native pond
thorn sand
#

oh you have extra files that you reference?

native pond
#

and my json

thorn sand
#

are they all in one folder?

native pond
#

txt is inside one

thorn sand
#

okay for the ones inside just do

native pond
#

if that makes sense

thorn sand
#

var = "folder/username.txt"

#

Like that

native pond
#

folder -> main.exe
folder -> config.json
folder -> folder -> txt

native pond
# thorn sand `var = "folder/username.txt`"

File "C:\Users\littl\Downloads\main.py", line 13
self.file_path = "folder\usernames.txt"
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 14-15: truncated \uXXXX escape

#

thats why u need double slash

#

but then it dont work

thorn sand
#

/ not \

native pond
#

true

#

@thorn sand all fixed

#

now

#

how do i send to him>

#

just compress?

thorn sand
#

Send him the folder containing your exe, config and assets

#

You can zip it if needed

native pond
#

the folder size

#

when ziped

thorn sand
#

wdym

#

Use an external hosting platform

native pond
thorn sand
#

Google drive

#

Or toffeeshare

#

Or riseup

#

Plenty of options

native pond
#

module

thorn sand
#

I'm not really sure, never used it and I don't know what your friends python environment is like

native pond
#

@thorn sand is there a way to manually download it?

timber pawnBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.