question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

command not found when I try execute shell script in jupyter cell

See original GitHub issue

Environment data

  • VS Code version: 1.67.0
  • Jupyter Extension version (available under the Extensions sidebar): 2022.4.1001271738
  • Python Extension version (available under the Extensions sidebar): 2022.6.0
  • OS (Windows | Mac | Linux distro) and version: Mac
  • Python and/or Anaconda version: python3.9
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): poetry
  • Jupyter server running: Local

Expected behaviour

image

Actual behaviour

image

Steps to reproduce:

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

This is due to my personal setup in zsh https://github.com/ztlevi/dotty-config/blob/652cff7fae4abadaa8016847933c71c235250b2d/env#L81

  • To reproduce, you’ll probably need to set zsh as default terminal in macOS. Newer macOS already use zsh by default.
  • Add the following code to your zshrc
function _load_all() {
  mkdir -p $HOME/Downloads
  local topics=($(ls $HOME/Downloads))
}
_load_all

Logs

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

info 17:27:20.562: Execute Cell 5 xxx.ipynb
info 17:27:21.148: Cell 5 executed with state Success

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ztlevicommented, May 16, 2022

Thanks. This one doesn’t work for me. I have to tweak a little bit.

  "jupyter.runStartupCommands": ["import os", "os.environ['PATH'] += os.pathsep+'/bin'"],
1reaction
DonJayamannecommented, May 16, 2022

@ztlevi thanks for getting back with the information. The path variables are inherited from the VS Code process. As you haven’t launched vscode from a shell process, the environment variables are completely different. Basically the vscode application (& other desktop applications) don’t initialize any shell scripts and use any of the initialization shell scripts. Jupyter application on the other hand is launched from a terminal, hence the difference in the bahaviour and values of the path variable.

As a temporary work around you could:

  • Open your user settings.json file and add the following contents
  "jupyter.runStartupCommands": [
    "import sys",
    "sys.path.append('/bin')"
  ]

Please note, this is only a work around and we’ll be looking into a more permanent fix as part of #9682

Read more comments on GitHub >

github_iconTop Results From Across the Web

After installing with pip, "jupyter: command not found"
Open a terminal window using Ctrl+Alt+T. · Run the command gedit ~/.profile. · Add the line. export PATH=$PATH:/.local/bin/jupyter-notebook. to ...
Read more >
zsh jupyter command not found - You.com | The Search Engine You ...
I've installed jupyter with pip a couple of weeks ago on my MacOS 10.15.7. I was executing it through the terminal perfectly so...
Read more >
What to do when things go wrong - The Jupyter Notebook
If you're using a menu shortcut or Anaconda launcher to start it, try opening a terminal or command prompt and running the command...
Read more >
Working with Jupyter Notebooks in Visual Studio Code
Visual Studio Code supports working with Jupyter Notebooks natively, ... When in command or edit mode, use Ctrl+Enter to run the current cell...
Read more >
Jupyter notebook support | PyCharm Documentation - JetBrains
With Jupyter Notebook integration available in PyCharm , you can easily edit, execute, and debug notebook source code and examine execution ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found