Prerequisites
- VS Code
- Python 3
It is recommended to install with homebrew
brew install python3
It is also possible to download and install from the official website
Open a Terminal to verify that you have installed successfully
python3 --version
Start the project
Create a new folder for the project and open it with Visual Studio Code. Create a new Python file hello.py
Paste the hello world code and save the file.
msg = "Hello World"
print(msg)
There are several ways to run the code
- the play button on the top right corner of vscode
- Right-click anywhere in the editor window and select Run Python File in Terminal
- Right-click the file and select Run Python File in Terminal
- Select the lines of code that you want to run, then press
Shift+Enter
Use packages
Set up the environment for the packages
python3 -m venv .venv
source .venv/bin/activate
You should notice the .venv (.venv) user@name
prefix in the terminal
Make sure the environment is set to the workspace environment that we have just created. Use the Python: Select Interpreter command from the Command Palette.
Install the packages
python3 -m pip install matplotlib
Now you can import are use the package
Top comments (0)