Help with Setting Up Visual Studio Code for Python

0
11
Asked By CuriousCoder27 On

I'm completely new to programming and just started taking CS50P. I downloaded Visual Studio Code and installed Python. When I tried to run a simple code snippet, `print("hello","world")`, in the terminal by typing `python hello.py`, I received a "zsh: command not found: hello.py" error. After searching for solutions, I tried `python3 hello.py`, but this time it didn't show any errors, just a blue circle indicating it's running. I'm unsure what to do next, especially since reinstalling Python from the official site didn't help. Can anyone provide some guidance?

3 Answers

Answered By TechSavvyNinja On

It looks like your terminal isn't pointing to the right folder where your `hello.py` file is saved. Make sure you navigate to the directory containing your Python script using the `cd` command. For example, if your file is in a folder called 'PythonProjects', you'd type `cd PythonProjects` before running the script again.

Answered By PythonNoobHelper On

You might be dealing with a PATH issue related to your Python installation. Since you mentioned that using `python3` didn't produce an error, that’s a good sign! Try running your script with that command, but ensure you’re in the correct directory first. You can double-check everything by listing the files in your directory using the `ls` command.

Answered By ScreenshotGuru On

It would be really helpful to see what's going wrong. If you could run `cat hello.py` to print out the contents of your file in the terminal and include that in a screenshot, that would clarify a lot. Just note, I can’t see screenshots here, but you could link to an image on a site like Imgur if you want!

CuriousCoder27 -

Thanks for the tip! I wanted to attach a screenshot here but couldn’t. I'll consider linking it on Imgur later.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.