Visual Studio Code#
If you use Visual Studio Code, you can connect your existing workspace directory and virtual environment in a few quick steps.
Install the Python Extension: Open VS Code, go to the Extensions view (
Ctrl+Shift+Xon Windows/Linux,Cmd+Shift+Xon macOS), and install the official Python extension published by Microsoft.Open the Project Folder: Select File > Open Folder… and select the project directory where you created your
.venv(or Conda environment) in Core Software.Select the Python Interpreter: You can see which Python interpreter VS Code is currently using in the bottom-right of the main window when a Python file is opened. VS Code usually detects and selects an existing
.venvfolder automatically. To explicitly set or change the active environment:Open the Command Palette using
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(macOS).Type and select Python: Select Interpreter.
Select your existing environment from the list:
For venv: Look for the recommended entry pointing to
./.venv/Scripts/python.exe(Windows) or./.venv/bin/python(macOS/Linux). If it doesn’t appear, select Enter interpreter path… and browse directly to the Python executable within.venv.For Conda: Select your named Conda environment (e.g.,
opensim-env).
Note
Once selected, opening a new terminal in VS Code (
Ctrl+Shift+`) will automatically activate your virtual environment.Verify OpenSim Import: Create a test script (e.g.,
test_env.py) or open the Interactive Window, then run:import opensim import opynsim print(opensim.__file__)
For further setup details, refer to the official VS Code documentation: