#๐Ÿ”’ cant open my python file pls help

99 messages ยท Page 1 of 1 (latest)

amber ledgeBOT
#

@pure zealot

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.

gritty ivy
#

elaborate

#

"cant even open the python file" makes no sense at all

#

i assume you need to open it in a text editor and not execute it

#

don't double click the file

#

open it in something like vscode

graceful valve
#

You need to run the file in your terminal or IDE

#

It's running but it's exiting quickly

gritty ivy
#

if you do need to run it then run it in your terminal

graceful valve
#

win+r, type cmd, and hit enter

#

That's okay we're going to make you feel less stupid right now.

#

send a screenshot

gritty ivy
#

once you open your terminal, cd into the folder where your python file is

#

now you need to cd into the correct folder, yes

#

cd means "change directory"

graceful valve
#

you type cd <directory name>

gritty ivy
#

we need to know where on your filesystem the python file is

#

give us an absolute path

graceful valve
#

Yeah so you see where that prompt says C:\Users\Oaklands?

gritty ivy
#

ok, you should type cd C:\Users\Oaklands\Downloads\myAppStarter in your terminal

graceful valve
#

That's your user directory

#

You can move around your filesystem like this

#

wherever you want to move

gritty ivy
#

once you do that you can run your python file using py myAppStarter.py

graceful valve
#

Did you change directories to the myAppStarter directory?

#

try going directory by directory

#

Do you know what a directory or a folder is?

#

Like Documents

#

Documents is a folder/directory

#

C:\ is a partition commonly called the C drive or your system drive

#

files are stored inside folders/directories

#

people use the word folder and directory interchangeably

gritty ivy
#

folder is windows, directory is linux

graceful valve
#

doesn't matter

#

try doing cd Downloads

#

yes

#

all of your user account stuff is stored inside your user folder

#

so that's where your downloads and documents folders are

#

or Desktop, or whatever

#

fantastic

#

Do you see the prompt shows Downloads in it now?

#

You shouldn't need to spam it.

#

Don't worry, spamming cd won't hurt your computer.

#

If you type dir you will see a list of files in your Downloads folder.

#

in a minute

#

dir is short for directory

#

that's how you can see what files or folders are inside a folder

#

now let's try something

#

You see everything in the Downloads folder

#

dir can show you more if you pass switches to it but I'll let you figure that out on your own later.

#

type cd my then hit the tab key

#

ok, sometimes it will autocomplete. But that's okay. finish typiing the name of that directory - myAppStarter

#

then after you're done hit enter

#

you should change to that directory

#

just type AppStarter to finish it

#

send a screenshot

#

oh you know what, it's not a directory

#

the py file is in your downloads folder

#

type py myAppStarter.py

#

hm. try python myAppStarter.py

#

Did you install Python?

#

You may not have added it to your path when you installed it is all.

#

You can definitely load it up in an IDE

#

oh there it is, it's python

#

ok, type dir myApp* (with the star) and hit enter

#

VS Code is popular.

#

it should show you if you have any files starting with those letters

#

ah

#

it's a zip file and you were navigating inside of it

#

ok, do you know how to unzip it?

#

in explorer right-click on that file and there should be an option to unzip it

#

sure

#

when that's done you should be able to cd myAppStarter

#

It was a compressed file and you just decompressed it.

#

now python myAppStarter.py

#

that will run that file

#

It did run. You got an error

#

so success!

#

It's giving you a ModuleNotFound error because you don't have the module installed.

#

That's easy enough to fix though

#

type dir requirements*

#

tell me if there is a requirements.txt

#

Ok that's fine. Sometimes Python applications will have a requirements.txt file with all the modules they need to run listed

#

So is this app from your school or what?

#

Ok. So since you're just getting started I would definitely recommend using VS Code or PyCharm or some other IDE

#

That will make things a lot more confusing ;P

#

But you'll get the hang of it.

#

haha

#

I'm kidding.

#

You will need to take some time to learn the tools though.

#

I think that's it.

#

no

#

Yeah go ahead and install it

#

follow the steps and it should guide you. You should be able to open up that file too.

#

I have to go now but if you need more help I'm sure somebody will be along

#

Good luck. I have faith in you.

frigid pollen
#

Do you skill need help?

amber ledgeBOT
#
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.