0

When i run pip3 install <package> or !pip3 install <package> or !pip install <package> i get this error. And also i can't clone any repo in jupyter. It gives the same error. This is my first time in Jupyter.

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
Input In [18], in <cell line: 1>()
----> 1 get_ipython().run_line_magic('pip', 'install boto3')

File /lib/python3.9/site-packages/IPython/core/interactiveshell.py:2294, in InteractiveShell.run_line_magic(self, magic_name, line, _stack_depth)
   2292     kwargs['local_ns'] = self.get_local_scope(stack_depth)
   2293 with self.builtin_trap:
-> 2294     result = fn(*args, **kwargs)
   2295 return result

File /lib/python3.9/site-packages/IPython/core/magics/packaging.py:75, in PackagingMagics.pip(self, line)
     72 else:
     73     python = shlex.quote(python)
---> 75 self.shell.system(" ".join([python, "-m", "pip", line]))
     77 print("Note: you may need to restart the kernel to use updated packages.")

File /lib/python3.9/site-packages/IPython/core/interactiveshell.py:2451, in InteractiveShell.system_piped(self, cmd)
   2446     raise OSError("Background processes not supported.")
   2448 # we explicitly do NOT return the subprocess status code, because
   2449 # a non-None value would trigger :func:`sys.displayhook` calls.
   2450 # Instead, we store the exit_code in user_ns.
-> 2451 self.user_ns['_exit_code'] = system(self.var_expand(cmd, depth=1))

File /lib/python3.9/site-packages/IPython/utils/_process_posix.py:148, in ProcessHandler.system(self, cmd)
    146     child = pexpect.spawnb(self.sh, args=['-c', cmd]) # Pexpect-U
    147 else:
--> 148     child = pexpect.spawn(self.sh, args=['-c', cmd])  # Vanilla Pexpect
    149 flush = sys.stdout.flush
    150 while True:
    151     # res is the index of the pattern that caused the match, so we
    152     # know whether we've finished (if we matched EOF) or not

File /lib/python3.9/site-packages/IPython/utils/_process_posix.py:57, in ProcessHandler.sh(self)
     55     self._sh = pexpect.which(shell_name)
     56     if self._sh is None:
---> 57         raise OSError('"{}" shell not found'.format(shell_name))
     59 return self._sh

I searched everywhere, but it is weird that no-one faced this issue except me. Pls provide some solution for this. I'm getting crazy.

Vijay P
  • 43
  • 1
  • 4
  • Did you install [Anaconda](https://www.anaconda.com/products/distribution) to get Python and Jupyter? It looks like you didn't, and you'd probably have better luck as someone new to use a distribution that handles for you a lot of making things work together on your machine. The modern approach to use `pip` inside a Jupyter notebook cell is `%pip install `. Similar for `%conda install`, see [here](https://discourse.jupyter.org/t/why-users-can-install-modules-from-pip-but-not-from-conda/10722/4?u=fomightez). Always best to include in your post what type of machine you are working on? – Wayne Mar 31 '22 at 15:35
  • Hey, I'm confused by your answer. Why should i install Anaconda to use Jupyter notebook. I tried using `%pip3 install `. It threw this `UsageError: Line magic function `%pip3` not found. ` Am i doing something wrong. I'm using the online [Jupyter](https://jupyter.org/try-jupyter/lab/) notebook, that's why i didnt mention my machine type. Jupyter labs is confusing. – Vijay P Apr 01 '22 at 06:22
  • Yes, if you are using an online source, you don't need to say what machine; however, providing such specifics is important. Rcecently the tour of JupyterLab available at that link changed to being backed by JupyterLite. Note the '**Experimental**' note [here](https://jupyter.org/try). The notebooks you get via JupyterLite are backed by pyolite running on your own machine & not a remote computer. Up until recently it ran on a remote machine that cost Jupyter folks money to run. This costs less; however is different in that it uses mircropip. It is simply meant to give a taste of JupyterLab. – Wayne Apr 01 '22 at 15:21
  • If can still use Jupyter on a remote computer for trying JupyterLab in a full-featured, more typical environment by going to ['JupyterLab + Binder' here](https://mybinder.readthedocs.io/en/latest/examples/sample_repos.html#jupyterlab-binder). Select the `launch binder` badge right under the title of that section. That will spin up a more typical Jupyter session & the notebooks will have a kernel like you are more familiar with backing them. Try `%pip install rich` in a cell in a notebook there & you'll see it install the package rich. These are temporary sessions that timeout after inactivity. – Wayne Apr 01 '22 at 15:28
  • I should have cited [this for further explanation of why the the demo was changed to use JupyterLite](https://discourse.jupyter.org/t/codes-on-https-jupyter-org-try-jupyter-lab-not-working-properly-anymore/13374/2?u=fomightez). And if you do want to use JupyterLite, this [here](https://stackoverflow.com/a/71712055/8508004) talks about how to install packages currently. Only a select number of modules support WASM, and thus work in JupyterLite. – Wayne Apr 01 '22 at 20:24

0 Answers0