I am currently trying to import spacy using Jupyter Notebooks and running into a problem. Every time I try to import it, it says that it cannot find the module, even though the regular python shell interpreter works just fine.
Information:
Conda Environment
installed using conda install -c conda-forge spacy
shows up in conda list | grep spacy
Jupyter can find other packages in the conda env, just not spacy
Thank you for any help you can provide.
EDIT: Terminal Commands:
1. cd into project directory
2. conda create -n <env name>
3. source activate <env name>
4. conda install -c conda-forge spacy
5. python -m spacy download en
6. python
- import spacy #works!
- nlp = spacy.load('en') #works!
- quit()
7. ipython
- import spacy
ModuleNotFoundError: No module named 'spacy'
EDIT2: Figured it out. My sys.path was different in ipython and wasn't searching through the conda env. I had to run conda install jupyter in the env and then everything worked. Apparently the root jupyter doesn't detect if you're inside an environment or not.
Figured it out. My sys.path was different in ipython v python shell. ipython wasn't searching through the conda env.
I had to run conda install jupyter in the env and then everything worked. Apparently the root jupyter doesn't detect if you're inside an environment or not. This makes sense now that I know some more about the internals as it needs to identify with a specific ipykernel.
Hope this helps anyone else running into the same issue.
create virtualenv
activate it
install jupyter and spacy on virtualenv
pip install jupyter pip install spacy
pip install ipykernel python -m ipykernel install --user --name=newkernelinvenv
start jupyter and load your new kernel
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With