I hit this problem as well. The best fix I could find was to create the Cusor rule shown below. I have it saved it to ./.cursor/rules/os-venv.mdc in my workspace.
It has pretty well has fixed the issue for me. Each time I invoke the agent, it makes sure my virtual environment is activated. Since I’m on Windows, I also put in an item saying, “figure out what OS you’re on.” Otherwise it would get into some pretty unproductive loops trying to run Unix commands on Windows.
---
alwaysApply: true
---
- When running commands in a terminal, look at the environment to determine what the operating system is, and use this information to run appropriate terminal commands.
- Always be sure that the Python virtual environment located at ./.venv is activated first.