Recall from WSL: Install Azure OpenAI SDK that in order to install the Azure OpenAI SDK on Ubuntu, a virtual environment had to be used. When running Visual Studio Code and developing with Python, the terminal associated with this virtual environment must be used; otherwise, the Azure OpenAI SDK-related packages will not be found.
This is not an issue when running an interactive terminal. Each time an interactive terminal is opened, .bashrc contains the following line, which facilitates access to the virtual environment:
The Ubuntu instance that is running will always access the virtual environment during development. Every time Visual Studio Code is launched from Ubuntu, the Python interpreter associated with the virtual environment must be used.
To set this behavior globally, as opposed to per-project, open Visual Studio Code from your WSL Ubuntu instance such as:
From Visual Studio Code, press Ctrl+Shift+P (Command Palette) and search for:
The example above is from my personal environment, so use your own specific virtual environment setup.
The python.defaultInterpreterPath setting points Visual Studio Code to your virtual environment. The setting python.terminal.activateEnvironment ensures it is auto-activated in the integrated terminal.
Once these changes have been made, save the file and close it.
Moving forward, every folder you open in Visual Studio Code will default to the virtual environment interpreter automatically.
This can also be configured on a per-folder basis by editing .vscode/settings.json, adding the following lines, and saving the file after modification:
Again, the settings shown above (python.defaultInterpreterPath) are specific to my environment, and you should use your own virtual environment settings.
No comments :
Post a Comment