You can specify the location of a Gurobi license file by setting the environment variable GRB_LICENSE_FILE. In some environments like interactive Jupyter sessions running in VSCode, it may be difficult to set such variables.
There is a dedicated Python package to set environment variables called python-dotenv (saurabh-kumar.com). This will read .env files in the current directory.
Using VSCode and Jupyter
The Jupyter extension of VSCode has built-in functionality to read .env files located in the workspace directory. It will read .env files in the workspace directory. Both the Jupyter Notebook execution and the Interactive Window will be affected by the .env file.