Skip to content
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

Jupyter Notebook does not execute !python or %run in the selected conda environment. #4682

Closed
spdavern opened this issue Feb 5, 2021 · 4 comments
Assignees
Labels
info-needed Issue requires more information from poster notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel)

Comments

@spdavern
Copy link

spdavern commented Feb 5, 2021

Environment data

  • VS Code version: 1.53.0
  • Extension version (available under the Extensions sidebar): v2021.1.502429796
  • OS and version: macOS 10.15.7
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.9
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: XXX
  • Relevant/affected Python-related VS Code extensions and their versions: XXX
  • Value of the python.languageServer setting: Jedi

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Expected behaviour

Python script run using !python or %run within a cell in a jupyter notebook uses the same environment as the jupyter notebook

Actual behaviour

Python script uses base conda environment rather than the selected conda environment

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Open Jupyter notebook in VS Code. Select a kernel with a Conda environment with a package that isn't in the base env.
  2. Run a .py script using ! python .py or %run .py that imports a package in the selected conda environment.

2021-02-04_18-16-43

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

@spdavern
Copy link
Author

spdavern commented Feb 5, 2021

To address the issues I deleted VS Code by opening my Mac Applications folder, right clicking on VS Code, selecting Move to Trash. I then downloaded VS Code 1.52.1 from here, unzipped the download, dragged VS Code back to my Applications folder. Opened VS Code and the Jupyter Notebook displayed above, re-ran the cells and NO ERROR! Conclusion: there is an issue with 1.53.0!

So, reverting from 1.53.0 back to 1.52.1 got me back to work but it doesn't fix the 1.53.0 issue.

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Feb 5, 2021
@claudiaregio
Copy link
Contributor

Thanks @spdavern! Will take a look as soon as possible

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Feb 18, 2021

@spdavern I'm sorry for not getting back to you on this issue.

  • Please could you ensure you have the
    • latest Jupyter extension installed
    • latest VS Code installed
  • Please could you enable logging as follows:
    • Open settings & go into Jupyter->Logging
    • Change the value to debug
    • Reload VS Code,
  • Attempt to repro the issue & then copy the output from the Jupyter output panel.

@DonJayamanne DonJayamanne reopened this Feb 18, 2021
@DonJayamanne DonJayamanne added info-needed Issue requires more information from poster notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel) labels Feb 18, 2021
@DonJayamanne
Copy link
Contributor

Closing this issue due to inactivity

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster notebook-kernel Kernels issues (start/restart/switch/execution, install ipykernel)
Projects
None yet
Development

No branches or pull requests

3 participants