#๐Ÿ”’ when i open py file it closes instant

225 messages ยท Page 1 of 1 (latest)

undone falcon
#

hi @candid rose

tight hawkBOT
#

@undone falcon

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.

candid rose
#

hey

undone falcon
#

soo

candid rose
#

how do you run the python file?

undone falcon
#

when i open py file

#

it closes

#

in this

#

python default

#

im newbie

candid rose
#

no worries

#

its not self evident that you have to use your terminal to run a python file

#

do you have windows terminal installed ?

undone falcon
#

yes

#

oh

#

what that means

candid rose
#

do you know how to open and use it?

undone falcon
#

wdym terminal

candid rose
undone falcon
#

command prompt?

candid rose
undone falcon
#

i have command prompt

candid rose
#

command prompt is very old...

#

better to use something new

#

but it will work from command prompt

undone falcon
#

so

#

i can never open

#

any py files

#

cuz it closes

#

in instant

candid rose
#

you can, but you dont know how to keep it open

#

thats why you need to run it from the terminal

undone falcon
#

okay how

dire willow
# undone falcon cuz it closes

This is the expected behaviour. If you double click a py file, it closes when it finishes, and that includes if the code has an error

candid rose
undone falcon
#

nope

candid rose
#

what version of windows do you have?

undone falcon
#

10

#

10 pro

candid rose
#

windows 10 is dead, but lets see if we can get you a new terminal and a new shell

#

open windows store

undone falcon
#

ye

candid rose
#

and in the search box, seartch for windows terminal

#

that is one of two programs you need

undone falcon
candid rose
#

yes thats the one

undone falcon
#

ok second

candid rose
#

on windows 11 it is installed by default

undone falcon
#

done

#

opened

#

it

candid rose
#

now search for an app called powershell

undone falcon
#

windows

#

powershell?

candid rose
#

in windows store

undone falcon
#

ok

candid rose
#

windows has two powershells

#

windows powershell and powershell

#

microsoft is really bad at naming things

undone falcon
#

done

candid rose
#

like they have two popular editors

undone falcon
#

now

candid rose
#

visual studio and visual studio code

#

๐Ÿ˜„

undone falcon
#

have it

candid rose
# undone falcon now

i want you to open a new terminal, use the pluss button and open the black powershell shell

undone falcon
#

uh

#

can i call

#

u

#

and screenshare

candid rose
#

you can use windows terminal settings to set this as the default shell

undone falcon
#

idk what im doing ngl

candid rose
#

screenshot works here

undone falcon
#

i dont really

#

understand

candid rose
#

no worries

undone falcon
#

i open vs?

candid rose
#

open windows terminal

undone falcon
#

ye

#

now

candid rose
#

you can make a new tab with the pluss symbol, next to it you have an arrow down

undone falcon
#

yup

candid rose
#

it shows you all your shells, one of them is the new powershell

#

it has a black icon

undone falcon
#

yup

#

opened

candid rose
#

while windows powershell has a blue one

undone falcon
candid rose
#

great, fantastic

#

where is your python script located?

undone falcon
#

dekstop

candid rose
#

cd Desktop

undone falcon
#

now

candid rose
#

this command changes directory to the desktop

undone falcon
#

yup

candid rose
#

dir to see all your files on the desktop

#

one of them should be your python file

#

disc_spider.py it should be named

undone falcon
#

ye

candid rose
#

now, lets check your python install first

#

py -0 run this please

#

share the result

undone falcon
candid rose
#

good

#

to run python from the terminal (on windows), you always use the py command

undone falcon
#

ye

candid rose
#

how did you get this file?

undone falcon
#

friend

candid rose
#

share the github page so i can see what you need to install to run it

undone falcon
#

nothing

#

is needed

#

and it aint github

#

only a file

#

he said nothing was needed

candid rose
#

and you dont find that suspicious? sounds like a bad friend is tricking you

#

type disc_spider.py and show me the top of the file

#

as a large screenshot

undone falcon
candid rose
#

type .\disc_spider.py

undone falcon
#

opened

#

and closed

candid rose
#

i forgot myself, you can use tab button to complete the name

#

type shows the content of the file on screen

#

you can just scroll up and see

undone falcon
#

what?

candid rose
#

i want to see the start of the file

#

to see what modules is needed to be installed

undone falcon
#

leme send u

candid rose
#

this is not something that works

undone falcon
#

really

candid rose
#

yeah, you cant get the ip of a discord user

#

and the code here does not work either

#

and the code also has requirements, so you cant just run it

candid rose
undone falcon
#

friend

#

sent me it

#

tho

#

he said

#

nothig

#

wasneeded

candid rose
#

and nothing there was true

undone falcon
#

can u tellme something that

#

shuts down

#

small websites?

candid rose
#

that would be illegal

undone falcon
#

really

candid rose
#

yes, its part of cyber crime, and it is illegal everywhere, and most places its also a fellony

#

what looks like a small thing is in fact really big because it has huge ramifications

undone falcon
#

oh

candid rose
#

you cannot attack only a small website, you will also attack all the small websites on that server, and take down multiple things, the entire network and everything in between

undone falcon
#

can u tell me smth fun

#

that i can have fun about

#

py thing

#

that i also can learn

#

how to open?

candid rose
#

well... there is a book called automate the boring stuff with python that not only teaches you python, but gives you the tools to do a lot of fun things for yourself

#

i use it to automate my house

#

i have built my own smart house

#

and it all starts out with small things

#

and to be honest, boring things! ๐Ÿ˜„

#

and now im automating something in a game i play beacuse i find something in that game to be so tedious and boring

undone falcon
#

lol

candid rose
#

you can find this book as a free ebook online as well

#

!res

tight hawkBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

candid rose
#

you find the link to it here

undone falcon
#

can u still teach me how to open file

candid rose
#

what file do you need to open?

undone falcon
#

ugh

#

uh

#

any

candid rose
#

programming is always specific

#

!docs open

tight hawkBOT
#

open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)```
Open *file* and return a corresponding [file object](https://docs.python.org/3/glossary.html#term-file-object). If the file cannot be opened, an [`OSError`](https://docs.python.org/3/library/exceptions.html#OSError) is raised. See [Reading and Writing Files](https://docs.python.org/3/tutorial/inputoutput.html#tut-files) for more examples of how to use this function.

*file* is a [path-like object](https://docs.python.org/3/glossary.html#term-path-like-object) giving the pathname (absolute or relative to the current working directory) of the file to be opened or an integer file descriptor of the file to be wrapped. (If a file descriptor is given, it is closed when the returned I/O object is closed unless *closefd* is set to `False`.)
candid rose
#

here is the general answer, but it might not help you much

undone falcon
#

oh

#

can u wait 5min

#

il find a file

candid rose
#

ofc i can, but how to open a file is also its own chapter in the book i shared above

#

not the first chapter, because you would need some basics first

undone falcon
#

okayy

#

help with his

candid rose
#

this is a mallicious tool that does not do what it say

undone falcon
#

bruh

candid rose
#

you just joined?

undone falcon
#

ye

candid rose
#

yeah..

#

and you said you agreed to our rules

#

but you never read them

#

#rules

undone falcon
#

yup

candid rose
#

you should

undone falcon
#

i be honest

candid rose
#

!rule 5

tight hawkBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

undone falcon
#

i didnt kenw

#

knew*

#

on god bro

#

im new too

#

i dont even know

#

how to open

#

py file

candid rose
#

but if you open this file, it will break something, steal something or worse

#

dont go looking for something like this online

undone falcon
#

broo

candid rose
#

i hear you say broo...

undone falcon
#

can u teach me at least

#

how to make a py code

#

in visual studio

#

and open it after

#

as exe?

#

like text

#

in terminal

#

ike

#

KENTI

1 - TYPE 1 FOR
2 - TYPE 2 FOR

candid rose
#

check the book i posted

undone falcon
#

okay

tight hawkBOT
#

:warning: The owner of this post is no longer in the server.

tight hawkBOT
#
Python help channel closed for inactivity

This help channel has been closed. 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.