In VSCode you could use python.envFile to point to an .env file that contains the PYTHONPATH for external imports. This is useful for monorepo setups that builds granularly.
I suspect since the move to cursorpyright that this feature is now lost in Cursor, rendering the entire development environment broken, as all external imports will no longer be picked up. This means that the agentic features are largely broken because the linting will never be able to be correctly resolved due to missing import errors.
Steps to Reproduce
Have python.envFile in settings. Note that external imports are no longer recognized in editor and module not found type checks occur.
Expected Behavior
Same as VSCode.
Operating System
Linux
Current Cursor Version (Menu → About Cursor → Copy)
Not working for me, or at least not for my use case, sadly. The “terminal.integrated.env” seems to allow environment variables to be set to the terminal, but it is unclear if that carries over to the in-editor linting environment via language servers.
My current workaround is to manually add lines to the “cursorpyright.analysis.extraPaths” setting, which is a pretty terrible solution considering the hundreds of external packages that might need to be resolved in a codebase.
Hi all, as a workaround, you can try customizing the node executable that runs the language server, and inject env variables either directly or via a wrapper script. Please see the settings cursorpyright.nodeEnvVars and cursorpyright.nodeExecutable.