-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test and run may use different python interpreters #335
Comments
Hello, Thank you for providing details for this issue. We will need to consider how we want to approach it however, as there currently isn't any language-specific behavior in the extension itself. Running python code via the editor is usually achieved with its own extension, while tests are run using an external Java process. For the desired solution we would need to find a reliable way to read this configuration from another extension (which isn't trivial as far as I know) and then patch the test running process in a way that works on all platforms. Unfortunately this dilemma also applies to error reporting. Without any information about the python environment configuration we necessarily can't distinguish between modules actually missing and python environments differing. |
I have been able to run the TestMyCode as you have suggested by launching Visual Studio Code from the terminal but now the normal execution ( Run python file in the terminal via green play button) is halted. |
Ongoing observations Same problem in any OS.
|
microsoft/vscode-python#12596 Possibility to pass the python executable path #408 to TMC Langs |
Hello @saskeli We release version 0.10.0 of the TMC extension in VSCode and would like to hear if this issue has been solved with the new release. Best regards, |
Description
If using a virtual environment python interpreter for completing exercises, one may run into problems where the interpreter set in VS Code is used for executing the python code, but tests run using the default python interpreter of a login shell.
This is (to my knowledge) only an issue when running linux and when using a non-Conda virtual environment.
Workaround
This can be fixed by making sure that the VS Code root process is started from a shell where the virtual environment is activated.
Example
Default python interpreter is
/usr/bin/python3
and the one used by VS Code is~/venv/bin/python
If numpy is installed in a virtual environment but not the system python, the code:
Will run fine, but tests will cause
If the missing import is instead in tests, the error will be along the lines of:
Desired solution
The optimal fix would be to have tmc test run using the same interpreter as VS Code is using by default.
If this is not possible/practical, the error reporting could be improved to point to the source issue.
The text was updated successfully, but these errors were encountered: