Is it possible to point Cursor/VSCode to a different python interpreter depending on file / directory location?
Our folder setup is as follows:
- /repo-root/
- /repo-root/app/
- /repo-root/app/foo/
- /repo-root/app/bar/
- /repo-root/app/baz/
foo, bar, and baz require distinct venvs / interpreters (all files within these directories use app’s venv). My interpreters/venvs are currently installed via pyenv at various locations, ie ~/.pyenv/versions/foo/bin/python or ~/.pyenv/versions/bar/bin/python
How can I let Cursor know to use the correct interpreter based on which file I’m working on? I can manually select the interpreter via dropdown on bottom right, but I hope I can tell Cursor about these automatically. This is possible in my current main IDE, JetBrains
Things I’ve tried
- Added a .pyrightconfig.json in each app directory with key “venvPath” pointing to correct venv
- creating a .env file with PYTHONPATH=<path to app’s venv> in each app diretory
- creating a .vscode/settings.json file in each app with key “python.defaultInterpreterPath” pointing to venv
Restarted after each change
None of these currently work