Setting Up a Python 3 Development Environment with VS Code
Posted by Ray Thurman on 08/24/2023
Creating a solid development environment is crucial for efficient Python development. In this tutorial, we will guide you through the process of setting up a Python 3 development environment on your local computer using Visual Studio Code (VS Code) as your code editor. We'll cover essential steps, including installing Git, setting up VS Code, and installing necessary tooling for Python development. By the end of this tutorial, you'll be well-equipped to start coding with Python in no time!
Step 1: Installing Git Git is a version control system that allows developers to track changes in their code and collaborate effectively. Follow these steps to install Git on your computer:
- Visit the official Git website (https://git-scm.com/) and download the installer for your operating system (Windows, macOS, or Linux).
- Run the installer and follow the on-screen instructions to complete the installation process.
- Once the installation is complete, open your terminal or command prompt and verify Git is installed by running the following command: git --version
- If Git is installed successfully, it will display the installed version.
Step 2: Installing Visual Studio Code (VS Code) Visual Studio Code is a popular and feature-rich code editor that provides excellent support for Python development. Here's how to install VS Code:
- Visit the official VS Code website (https://code.visualstudio.com/) and download the installer for your operating system.
- Run the installer and follow the on-screen instructions to install VS Code.
- After the installation, launch VS Code by clicking on its icon in the applications folder (macOS) or the Start menu (Windows).
Step 3: Installing Python Extension for VS Code To enable Python development in VS Code, you'll need to install the Python extension. Follow these steps:
- Open VS Code.
- Click on the Extensions icon in the sidebar or press Ctrl+Shift+X (Cmd+Shift+X on macOS).
- Search for "Python" in the Extensions Marketplace search bar.
- Click on the "Python" extension by Microsoft and click the Install button.
- Once the installation is complete, click the Reload button to activate the extension.
Step 4: Setting Up a Python Virtual Environment A virtual environment allows you to isolate Python dependencies for different projects, ensuring a clean and consistent development environment. To set up a virtual environment, follow these steps:
- Open your terminal or command prompt.
- Create a new directory for your Python project and navigate into it: mkdir my_python_project cd my_python_project
- Create a virtual environment using the following command: python3 -m venv venv Replace "python3" with the appropriate Python 3 executable if needed.
- Activate the virtual environment: On Windows: venv\Scripts\activate On macOS and Linux: source venv/bin/activate You'll know the virtual environment is active when you see "(venv)" at the beginning of your command prompt.
Step 5: Installing Python Packages With your virtual environment activated, you can now install Python packages specific to your project. Use the "pip" package manager to install packages: pip install package_name Replace "package_name" with the name of the package you want to install.
Step 6: Creating a Python Project in VS Code Now that you have everything set up, it's time to start coding in VS Code. Here's how to create a new Python file:
- Open VS Code and click on the "Explorer" icon in the sidebar.
- Right-click on your project folder and select "New File."
- Name the file with the .py extension (e.g., main.py).
- Start writing your Python code in the new file.
Conclusion Congratulations! You've successfully set up a Python 3 development environment on your local computer using VS Code as your code editor. You're now ready to write Python code and take advantage of the powerful features and tooling provided by VS Code and Git. Happy coding!
Check out these great products!
If you find my content valuable, please consider supporting me by buying me a coffee or checking out one of my recommended books on software development. Your support is greatly appreciated!
Copyright © 2025 Ravenwood Creations