1

I want to create a new python file by using:

code filename.py

But I get:

~ % code file.py zsh: command not found: code

I learned that I could not run a program from the command-line with: python filename.py zsh: command not found: python

I have to use python3 filename.py

Is there a similar solution here?

1 Answer 1

6

You can run VS Code from the terminal by typing 'code' after adding it to the path:

  1. Launch VS Code.
  2. Open the Command Palette (Cmd+Shift+P) and type 'shell command' to find the Shell Command: Install 'code' command in PATH command. enter image description here
  3. Restart the terminal for the new $PATH value to take effect. You'll be able to type 'code .' in any folder to start editing files in that folder.
Sign up to request clarification or add additional context in comments.

2 Comments

What OS are you on? I do not have shell command: on Windows or WSL2!
I'm on macOS. On Windows, you may need add VS Code binaries location to your system path. The default VS Code binaries location is AppData\Local\Programs\Microsoft VS Code\bin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.