TLDR: I’m simple and need help. I’m new to Linux in general and just want python/script files to open and run in the terminal/an interpreter like in windows
So I’ve basically tried the simplest solutions, like going into properties and making it executable, using a bash script to launch it in the konsole and use the python command to enter the python interpreter and execute it through that… I’m new to this, I’m tired, and I would use bash but it returns a file not found error, which after some quick research found it would be less complicated to just use alternative interpreters/languages like python, pearl, now, while it seems simpler to do just that, the simplicity is lost on me and can’t seem to quite understand how to make this goal of mine possible “easily” as in “new to the command line period” level, easy.
While I understand the feeling of frustration, let me just tell you: Linux is not Windows and I think you should go thorough this: [HowTo] become a Manjaro power user when you're a wizard at Windows but a N00b at Manjaro / Linux
Then, in order for anyone to be able to help you, please see How to provide good information, and edit your post accordingly.
If you know how to run scripts in powershell - you know you need to add the current folder to the command line.
- a script file includes the
#!prefix indicating which interpreter to use e.g. python would be
- a script file must be executable to run from the commandline
chmod +x your-script
- you use
/ instead of
\ so a script becomes
If you have the interpreter installed, you can either run a python script with simply
or you can give it execute permissions with
chmod +x file.py
, add the “shebang” to the top of your script (
#!/usr/bin/env python or
#!/usr/bin/python) and then you can run it like a normal program with
if you’re in the same directory.
You can also do the latter method without giving a
.py extension to your script.
if script is not in one $PATH directory, always add path for run this program. we can use absolute or relative path to current directory
~/script # "~/" for linux is the user home directory
And linux is case sensitive :
./Myscript # not found
./myscript # ok
linux does not use the file extension to launch the interpreter but the first line in code : the shebang
In addition to this, if you don’t want to mess with the
$PATH variable, I’d recommend placing your scripts in
~/.local/bin and they should run without needing to give the full path.