The code I wrote in VSCode does not work


New Member
Sep 10, 2022
Reaction score
I am using ubuntu. I writing a python code but it doesn't work.

berat@berat-Latitude-E5470:~$ /bin/python3 "/home/berat/print("hello world").py"
/bin/python3: can't open file '/home/berat/print(hello': [Errno 2] No such file or directory

please help me, i am inexperienced in ubuntu.

The problem there is the filename you’ve chosen for your script. Because you’ve used some special characters in your file-name, you’ll need to escape them with backslashes.

python3 "/home/berat/print\(\"hello world\"\).py"

Personally, I’d recommend renaming the file to something like Would make it a lot quicker to type in the terminal!

Then you could run your script like this:
python3 ~/

Note ~ is a convenient shell shortcut that expands to the path to your home directory. Which in your case is /home/berat. So any time you need to type the path to your home directory, instead of manually typing the path, you can use ~/ instead.

Additionally, if you put a shebang line as the very first line in your Python scripts:
#!/usr/bin/env python3
print("hello world")

And then make your script executable using:
chmod +x ~/

Now you can run your script directly, without having to specify Python3:

When you run your script, what happens is:-
Bash will read the first line of the script - the shebang line, which tells bash to run the file in python3.
The shell will then load and run your script in the Python3 interpreter.

When the Python3 interpreter runs your script, it will see the shebang line as a comment and will ignore it. So the shebang will not have any negative affect the rest of your script. It literally just tells the shell which interpreter/executable to run your script through.

I hope that all makes sense?!
If not, feel free to ask more questions!

Members online