'Why pip install not working in Jupyter notebook?

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.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source