DEV Community

Giovanni Fu Lin
Giovanni Fu Lin

Posted on • Edited on

2

Quick Setup for new Python Project on Mac M1

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
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Now you can import are use the package

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay