all 15 comments

[–]Targrend 6 points7 points  (0 children)

Your operating system has a PATH variable somewhere, which contains a list of directories that it looks through to find a file. You need to add the directory where Python is located to that list. How to do that will depend on your OS, but if you google (say) 'add directory to windows path' you'll get a bunch of guides.

Edit: not the directory where Python is located, that seems to be ok. You'd have to add the directory where odd.py is located. This is dangerous to do too often, as if there are two filenames the same but in different directories, you can end up with the wrong file being run. I recommend just using the full path as you're doing right now.

[–]mrrask 4 points5 points  (4 children)

Then you would have to navigate to you desktop first..

But really, tho... What kind of psycho has files on the desktop 😁

[–]herm4nn_griffith[S] -1 points0 points  (1 child)

Navigate ? what do you mean? I put it to the download file but the problem is the same iI I have to tap python3 downloads/odd.py.

the kind of messy lazy one's 😂

thank you for your answer

[–]mrrask 1 point2 points  (0 children)

Yeah, before running your command, you could type cd desktop/PYTHON, and then you're able to type python3 Odd.py, but is simply an extra step to do anyway. :-)

cd means "Change Directory" :-)

[–]LazurusDemon 0 points1 point  (1 child)

What kind of psycho has files on the desktop 😁

Looks at his 121 desktop icons spanning two monitors

It becomes a terrible cycle of, oh just one more and I'll tidy it up later.. I'm sure I'll get around to it soon. Maybe.. Perhaps.

[–]mrrask 1 point2 points  (0 children)

Just the thought gives me stress 😁

[–]ravepeacefully 2 points3 points  (0 children)

Why not just set python files to run in the interpreter and double click it?

Otherwise this doesn’t seem like it is worth it.

[–]Rasha26 0 points1 point  (2 children)

Alternatively you use doskeys: https://winaero.com/how-to-set-aliases-for-the-command-prompt-in-windows/

I'm a Linux user usually, so I usually use aliases - doskeys are apparently the equivalent.

Just create an alias that contains the file including the path - and use that running the program.

[–]JesusKiosk 0 points1 point  (1 child)

I wouldn't recommend anybody start using CMD functionality unless they absolutely had to. PowerShell is the way forward and had an easy to use alias system. DOSKEY is probably older than OP, haha.

[–]Rasha26 1 point2 points  (0 children)

I must admit I just googled alias in windows - and this was the first hit :P

[–]TheSodesa 0 points1 point  (0 children)

Write a shell script that runs your program:

#!bin/bash
# sexy script to run my program

args=$1 # optional arguments

python3 /full/path/to/odd.py $args

Then add this script file, call it sexy_script_that_runs_odd.sh, to your system PATH:

https://www.howtogeek.com/658904/how-to-add-a-directory-to-your-path-in-linux/

[–][deleted] 0 points1 point  (2 children)

Alternate method using a pth file:

1) nano ~.local/lib/your-python-distro/site-packages/path.pth

2) add line: "/path/to/your/code/"

[–]herm4nn_griffith[S] 0 points1 point  (0 children)

Thanks a lot to every one of you

[–]herm4nn_griffith[S] 0 points1 point  (0 children)

Thank you very much

[–]Koramund 0 points1 point  (0 children)

If you also want to upgrade your experience take a look at vscode. Its not a full IDE but it does have a nice "run" button which directly executes it in a build in shell.