Cannot import spacy -Jupyter python 3 notebook - python-3.x

I am trying to create a jupyter notebook for an NLP project and I am failing to import spacy. I get the error below
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-102-728c089140d2> in <module>
6 import numpy as np
7 import re
----> 8 import spacy
9
10 # libraries for visualization
ModuleNotFoundError: No module named 'spacy'
May anyone help with suggestions ?

If you're using Conda:
import sys
!conda install --yes --prefix {sys.prefix} spacy
Otherwise, use pip:
import sys
!{sys.executable} -m pip install spacy

Related

Import Simpy in Python 3

I am unable to import simpy in Python 3. It gives me this error
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-6-076c1059698e> in <module>
----> 1 import simpy
ModuleNotFoundError: No module named 'simpy'
Please tell me a way to do so?
Make sure the package is installed and available in your environment, as that is a common error when the package is not present.
Run:
pip install simpy
or if you have separate Python versions on your system:
pip3 install simpy
Or, if installing from the source code:
python setup.py install
or,
python3 setup.py install

Cannot import tensorflow in Spyder but it imports in python

I installed Anaconda on my machine and created a separate environment for tensorflow. Installed tensorflow and keras ok but both packages cannot be imported. The error is:
In [1]: import tensorflow
Traceback (most recent call last):
File "<ipython-input-1-88d96843a926>", line 1, in <module>
import tensorflow
ModuleNotFoundError: No module named 'tensorflow'
Dependencies that were installed during the install like scipy and yaml can be imported.
When I run python3 from the command line I can import keras and tensorflow correctly. This fails when I try to import tensorflow in Spyder.
I rebooted, uninstalled and installed again. I am sure that I am in the correct environment. Does somebody know what I do wrong?

import Statsmodels issue

I have the latest Anaconda distribution and running Jupyter notebooks 6.0.2 with Python 3.7.
I am trying to import statsmodels and I am getting the following error.
I have done the
pip install statmodels
import statsmodels.api as sm
or
import statmodels
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-2fcb280597c8> in <module>
----> 1 import statmodels.api
ModuleNotFoundError: No module named 'statmodels'
Please help
Doing the following worked for me.
pip install git+https://github.com/statsmodels/statsmodels

Library installed and shown in conda, but not usable in Jupyter Notebook

The pillow library is installed via conda, and the status is verified in the jupyter notebook. However when I try to import pillow library in the same jupyter notebook instance, I cannot find this library.
I tried to manually run jupyter notebook cli in conda environment (with pillow installed), as well using anaconda GUI shortcuts, none of them could find pillow library.
!conda list pillow
import pillow
Output
# packages in environment at C:\ProgramData\Anaconda3\envs\jupyter:
#
# Name Version Build Channel
pillow 6.0.0 py37h9a613e6_0 conda-forge
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-6-dc0fbd63c36f> in <module>
1 get_ipython().system('conda list pillow')
----> 2 import pillow
ModuleNotFoundError: No module named 'pillow'
pillow is a fork of PIL (Python Imaging Library) so it can't be imported, it's PIL that is imported.
Use:-
import PIL
or import any specific module by
from PIL import Module_name

numpy intalled with pip but not found (in virtualenv)

In an AWS EC2 instance, with Amazon Linux AMI 2016.09 distribution, I have installed numpy, inside my virtualenv where python 3.4 is the default version, with:
pip install numpy
It installs package numpy-1.12.1-cp34-cp34m-manylinux1_x86_64.whl without errors.
After that, in python I try to import it:
>>> import numpy
And I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
Moreover, if I run pip freeze, numpy does not appear in the list.
Why is numpy not being found? and How to fix it?
Did you do this:
#:source .venv/bin/activate
.....
#:python
....
>>>pip3 install numpy
....
This works!

Resources