I am trying to run a simple "Hello World" script which is named print("hello world!").py
by pressing the "play" button in the top-right of the VS Code window.
I’m using Python 3.13.0, macOS 12.6.1 and VS Code 1.94.
The VS Code terminal prints:
dafyddpowell@Dafydds-MBP ~ % cd "/Volumes/SAMSUNG/Python projects"
dafyddpowell@Dafydds-MBP Python projects % /usr/bin/python3 "/Volumes/SAMSUNG/Python projects/print("Hello world!").py"
zsh: parse error near `)'
dafyddpowell@Dafydds-MBP Python projects %
What is wrong?
3
Answers
Use a file name something like "print_hello_world.py".
It seems like VSCode isn’t escaping the file name that contains special characters.
The simplest way around this would be to use a filename that doesn’t have any special characters like
hello_world.py
.If the underlying shell is bash (or equivalent in terms of how the command line is interpreted) then:
Whilst the filename is legal, it’s not very sensible