Nope, that's not needed. But for every project, it is recommended that you always create and activate a python virtual environment using:
# This command runs the Python venv module and creates a virtual environment in a folder named .venv.
py -3 -m venv .venv
# Activate the virtual environment
.venvscriptsactivate
A virtual environment is a folder within a project that isolates a copy of a specific Python interpreter. Once you activate that environment (which Visual Studio Code does automatically), running pip install
installs a library into that environment only.
When you then run your Python code, it runs in the environment's exact context with specific versions of every library. You can create a requirements.txt
file for the libraries you need, then use pip install -r requirements.txt
.
Here is a snippet from a sample requirements.txt file:
azure-cli-core==2.11.1
azure-cli-telemetry==1.0.6
azure-common==1.1.25
azure-core==1.8.1
azure-identity==1.4.0
azure-mgmt-compute==17.0.0
azure-mgmt-core==1.2.0
azure-mgmt-network==16.0.0
azure-mgmt-resource==10.2.0
If you don't use a virtual environment, then Python runs in its global environment that is shared by any number of projects.
Refer to the Azure SDK for Python Developer docs for more information on configuring your local Python dev environment for Azure.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…