-
Notifications
You must be signed in to change notification settings - Fork 1.2k
opening jupyter notebook tries to activate wrong env #14902
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
Comments
I forgot to mention it was working well before. I updated VS Code and installed two Docker extensions before I realized I had the problem. |
The Jupyter extension relies on the Python extension to retrieve activated environment variables for the selected interpreter, we don't compute that ourselves. In this case it seems like the the activation command is not being correctly computed. The code for that is here:
|
Thank you, I took a look at what you showed me. Yes, I can see all that is happening but I dont know how to fix it. This is what I see happening:
the value 'source' is passed to const activationCommands here, the value 'source' gets transformed into a 'dot' (" . "):
later, when this line executes:
I can see this in the jupyter terminal output: vs code pops this message: These two messages differ in that one shows the word 'activate' after the "dot" In any case neither way will activate the env. If the function 'getEnvironmentActivationShellCommands' in line 156 wouldnt pass 'source' as a value, it wouldnt get replaced by the "dot" and perhaps the command wouldnt fail. Not sure if that is a solution. If it is, what would be the next step? I dont know where that file is in my computer. I cannot find it anywhere. Thank you! |
Hey @montythepython 👋 Your issue seems very similar to #14123. I think it might be that you don't have the conda |
hi @karrtikr! Thank you for the link! it solved the problem. In my case I only had to uncheck: Everything was working before, so somehow that got globally checked and things stopped working. maybe after updating VS Code. @karthiknadig (thanks for your post!) recommends to change this setting ideally only for the project and not for the VS Code "User". I have the same problem with every project so I guess in my case it would be better to uncheck for User. Thank you! |
Alright, #14902 (comment) is still helpful in case you need to check it for user settings as well. Closing this. |
Environment data
Expected behaviour
To be able to run python code in a jupyter notebook inside of VS Code using the jupyter extension
Actual behaviour
When I open a notebook inside of VS Code (and everyime I try to run code inside), I get this:
Command failed: . activate /home/arthur/Documents/sqliteTest/env && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /home/arthur/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py /home/arthur/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/printEnvVariables.py bash: activate: No such file or directory
After attempting that for the first time, everytime I open the integrated terminal in VS Coded, it tries to do this:
source activate /home/arthur/Documents/sqliteTest/env
and I right after:
bash: activate: No such file or directory
The path to the env is correct. It also seems to be running the right Python Interpreter: ./env/bin/python3.7
If I just change the word "source" for "conda":
conda activate /home/arthur/Documents/sqliteTest/env
the env activates without a problem but if I try to run code from my notebook inside VS Code, I get the same result:
Command failed: . activate /home/arthur/Documents/sqliteTest/env && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /home/arthur/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py /home/arthur/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/printEnvVariables.py bash: activate: No such file or directory
If I activate the env and then type jupyter notebook, I can see it on my localhost and all works fine
Steps to reproduce:
Logs
User belongs to experiment group 'AlwaysDisplayTestExplorer - control'
User belongs to experiment group 'ShowPlayIcon - start'
User belongs to experiment group 'ShowExtensionSurveyPrompt - control'
User belongs to experiment group 'DebugAdapterFactory - experiment'
User belongs to experiment group 'PtvsdWheels37 - experiment'
User belongs to experiment group 'UseTerminalToGetActivatedEnvVars - control'
User belongs to experiment group 'AA_testing - control'
User belongs to experiment group 'LocalZMQKernel - experiment'
User belongs to experiment group 'CollectLSRequestTiming - control'
User belongs to experiment group 'CollectNodeLSRequestTiming - experiment'
User belongs to experiment group 'EnableIPyWidgets - experiment'
User belongs to experiment group 'DeprecatePythonPath - control'
User belongs to experiment group 'RunByLine - experiment'
User belongs to experiment group 'CustomEditorSupport - control'
User belongs to experiment group 'pythonaa'
killed: false,
code: 1,
signal: null,
cmd: ". activate /home/arthur/Documents/sqliteTest/env && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /home/arthur/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py /home/arthur/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/printEnvVariables.py"
}
Error 2020-12-05 21:58:04: getActivatedEnvironmentVariables, Class name = P, completed in 661ms, has a falsy return value, Arg 1: undefined, Arg 2: {"architecture":3,"path":"/home/arthur/Documents/sqliteTest/env/bin/python","version":{"options":{"loose":false,"includePrerelease":false},"loose":false,"raw":"3.7.8-final","major":3,"minor":7,"patch":8,"prerelease":["final"],"build":[],"version":"3.7.8-final"},"sysVersion":"3.7.8 | packaged by conda-forge | (default, Nov 27 2020, 19:24:58) \n[GCC 9.3.0]","sysPrefix":"/home/arthur/Documents/Dev/codecademy_data_science/sqliteTest/env","fileHash":"bb92ae2f6b688b7455e48aed14639ad25c9cf4153ae644aa92ad57f3ee5b2ebb622209bd4105923dbf5f8266c7ec961d65c0a105d09d1a7237d9958d3ffd59bc","companyDisplayName":"Anaconda, Inc.","envType":"Conda","envPath":"/home/arthur/Documents/sqliteTest/env","envName":"","displayName":"Python 3.7.8 64-bit (conda)"}, Arg 3: true [Error: Command failed: . activate /home/arthur/Documents/Dev/codecademy_data_science/sqliteTest/env && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /home/arthur/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py /home/arthur/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/printEnvVariables.py
bash: activate: No such file or directory
killed: false,
code: 1,
signal: null,
cmd: ". activate /home/arthur/sqliteTest/env && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /home/arthur/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py /home/arthur/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/printEnvVariables.py",
vslsStack: [
CallSite {},
CallSite {},
CallSite {},
CallSite {},
CallSite {},
CallSite {}
]
}
The text was updated successfully, but these errors were encountered: