0

Here is the code I'm trying to use:

import sys
!{sys.executable} -m pip install spacy
!{sys.executable} -m spacy download en

This is the response:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
Input In [12], in <cell line: 2>()
      1 import sys
----> 2 get_ipython().system('{sys.executable} -m pip install spacy')
      3 get_ipython().system('{sys.executable} -m spacy download en')

File /lib/python3.9/site-packages/IPython/core/interactiveshell.py:2442, in InteractiveShell.system_piped(self, cmd)
   2437     raise OSError("Background processes not supported.")
   2439 # we explicitly do NOT return the subprocess status code, because
   2440 # a non-None value would trigger :func:`sys.displayhook` calls.
   2441 # Instead, we store the exit_code in user_ns.
-> 2442 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

OSError: "sh" shell not found

Also, the instructions I am following say I need to select File, New Notebook, Python 3. But I can only select File, New Notebook, and then a popup asks me to select a kernal. Does that matter? (I have tried all kernal options.)

The frustrating thing is that I did this same tutorial a few weeks ago and it worked fine.

[Edit: Thank you to everyone who is helping me figure this out, but unfortunately none of these solutions are working. I looked at the link provided by JonSG, but I'm afraid it's all greek to me. I'm starting to think this is an issue with Jupyter, rather than the code. Again, I appreciate the help, but I'm throwing in the towel.]

arbo
  • 1
  • 1
  • Does this answer your question? [Installing a pip package from within a Jupyter Notebook not working](https://stackoverflow.com/questions/38368318/installing-a-pip-package-from-within-a-jupyter-notebook-not-working) – JonSG Mar 16 '22 at 15:23
  • Does this work: `%pip install spacy`? – JonSG Mar 16 '22 at 15:25
  • try `!pip install spacy` and then `!python -m spacy download en_core_web_sm` – Talha Tayyab Mar 17 '22 at 03:06

1 Answers1

0

hi i was also having trouble installing spacy and its modules on jupyter notebook and somehow found the way. I don't know if you still need it, but in case someone gets led to here in the future I'm just gonna paste what I did here:

pip install spacy
!python3 -m spacy download en_core_web_sm
sf_Tg
  • 1
  • 2