In my earlier article, I have explained how to upgrade Python on macOS and setup Visual Studio Code project for Python development. Now we will see how to upgrade the already setup Python environment in VS Code workspace.
In my current Python workspace, the interpreter is pointing to a virtual environment with Python 3.7.3. To upgrade this to version 3.7.4, I’ve followed these steps.
When upgrading the python interpreter version in python workspace, you may encounter errors or warnings while running the project because of incompatible usage of methods or objects. So please review the release documents from python.org before upgrading and prepare an action plan to migrate the code to new version of Python.
- VS Code should be setup to use Python.
- A Python virtual environment should be created for the VS Code workspace.
- Python should be upgraded on macOS to the desired version which you want to use in the VS Code workspace. Here in my case its 3.7.4
Steps to upgrade Python in workspace
- Launch the Visual Studio Code python workspace.
- Open the Command Palette, by pressing Shift, Command and P keys.
- In the Command Palette, type in and select Python: Select Interpreter.
- The available interpreters will be listed. You can see the newly upgraded version (3.7.4) of python global environment and the virtual environment listed.
- Select the virtual environment Python 3.7.4 64-bit (‘env’: venv).
- From now on, the VS Code workspace will use the environment with the new version of Python.
Tools & Technologies Used
- macOS Mojave (10.14.6)
- Visual Studio Code (1.37.1)
- Python (3.7.4)