Cannot Import Textblob In Jupyter After successfully installing it - python

I have downloaded and installed textblob using pip and now while i am importing it on jupyter notebook i get an error as:
No module named 'textblob'
Have checked Link1 and Link2 amongst other similar thread on SO but following the recommended steps i am not still able to download it.
Running CMD as an administrator i am getting this error while trying to load the package again:
Requirement already satisfied, skipping upgrade
This is how i am calling it in jupyter -
from textblob import TextBlob
pip version - pip 19.0.3

Related

Python Error ModuleNotFoundError: No module named 'transformers'

I'm getting below error when running 'import transformers', even though I have installed in the same vitual env. I'm using python 3.8
ModuleNotFoundError: No module named 'transformers'
Error:
enter image description here
I have uninstalled it and reinstalled it using 'pip3 install transformers' from python cmd line.
Then I tried to uninstalled again, and reinstalled in jupyter notebook using '!pip install transformers', result shows '
Installing collected packages: transformers
Successfully installed transformers-4.24.0
'
I can also verify directly in Jupyter Notebook:
enter image description here
I tried to install transformers successfully in jupyter Notebook. After that still getting ModuleNotFoundError error (have tried restarted kernel too)
enter image description here
its resolved now. I just tried to use %pip install transformers==3.4.0, instead of !pip install transformers==3.4.0 in jupyter book, and it worked. I can proceed with the project for now. Although I don't know what I did wrong in my python command line earlier that caused the inconsistency. Will open a new thread.

Jupyter Notebook ModuleError after Homebrew Upgrade

I have been using Jupyter for some time now and it has worked just fine. I have Jupyter and Python installed via Homebrew. I am running on MacOS.
Yesterday, I ran the command brew upgrade and now my Jupyter notebook is unable to find any of the installed python packages. I will use Numpy as the example.
When inside of a Jupyter notebook, I try to do
import numpy
I get the message:
ModuleNotFoundError: No module named 'numpy'
If, however, I launch python in a terminal window, then I can import Numpy without issue.
I first checked that the package was installed correctly by re-issuing the install command
brew install numpy
which outputs:
Warning: numpy 1.18.4 is already installed and up-to-date
To reinstall 1.18.4, run `brew reinstall numpy`
I also ran
pip install numpy
and got:
Requirement already satisfied: numpy in /usr/local/lib/python3.7/site-packages (1.18.4)
Now, this is where I got confused because I expected the path to point to something like /usr/local/Cellar/, so I checked the path inside of the Jupyter notebook:
import sys
sys.path
which outputs:
['/Users/kseuro/Dropbox/Dev/',
'/usr/local/Cellar/jupyterlab/2.1.2/libexec/lib/python38.zip',
'/usr/local/Cellar/jupyterlab/2.1.2/libexec/lib/python3.8',
'/usr/local/Cellar/jupyterlab/2.1.2/libexec/lib/python3.8/lib-dynload',
'/usr/local/opt/python#3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8',
'',
'/usr/local/Cellar/jupyterlab/2.1.2/libexec/lib/python3.8/site-packages',
'/usr/local/Cellar/jupyterlab/2.1.2/libexec/lib/python3.8/site-packages/IPython/extensions',
'/Users/kseuro/.ipython']
Ok, so Homebrew wants Jupyter to use Python3.8? So I tried brew switch python 3.8 and got:
Error: python does not have a version "3.8" in the Cellar.
python's installed versions: 3.7.7
I feel like I'm out of my depth now and need help figuring out what to do next. I don't want to start by just changing paths around.
Suggestions? Thanks so much.
I figured out what to do — posting the solution for my future self and others who may stumble upon this.
Since Jupyerlab is in its own Cellar, the Python packages need to end up in the
/usr/local/Cellar/jupyterlab/x.y.z/libexec/lib/python3.x/site-packages
directory, where x, y, z are integers, so that the Jupyter kernel can find them.
You can do this by calling:
import sys
!{sys.executable} -m pip install 'package-name'
inside of the Jupyer notebook.
All is well, again.

Trouble importing Tabulate with Python 3.7

I'm running Python 3.7 on Windows 10 and I keep getting No module named 'tabulate' error. I have deleted Python 2.
I've tried everything suggested in a similar question:
>> pip install tabulate
>> pip3 install tabulate
>> python -m pip install tabulate
All of the above respond with
>> Successfully installed tabulate-0.8.6
If I try to run it again, I get
>> Requirement already satisfied: tabulate in c:\program files\python37\lib\site-packages (0.8.6)
But I keep getting the same ModuleNotFoundError when I try to import it. What can I try still?
UPD:
I have double-checked whether old versions of Python were uninstalled, and to my surprise EVERYTHING was still there: the folders, the files, the paths in the PATH... I'm afraid that was the reason of my problems, but I won't be able to test it until later.
I solved this issue by updating tabulate to the latest version using:
pip install --upgrade tabulate

ModuleNotFoundError: No module named 'spatial'

I've been faced to Module Not Found Error in a script which all it's requirements has been installed. I'm trying to import spatial library:
import spatial
This library is located here:
C:\Users\ASUS\AppData\Local\Programs\Python\Python37\Lib\site-packages\scipy\spatial
I checked installed packages through pip list and it was okay. I tried to install spatial-lib in Pycharm project environment but it couldn't be done:
Could not find a version that satisfies the requirement spatial-lib (from versions: )
No matching distribution found for spatial-lib
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
It's nonesence, because my pip is up-to-date. Maybe good to say, importing scipy has such probelms too.
It looks like spatial is a sub-package of scipy. Therefore, to import spatial, you should use the following:
from scipy import spatial

No module named openpyxl - Python 3.6 - OSX

I've installed openpyxl from the Terminal using
pip3 install openpyxl
without any problems. I've even double-checked by simply running import openpyxl from the Terminal window once Python is running, and it imports no problem.
The problem starts when I try and import openpyxl from a script I'm building to work with a spreadsheet. I'm using Sublime Text and can't even get past the import openpyxl at the beginning of the script without running into the following error:
Traceback (most recent call last):
File "/Users/wcw/Desktop/test.py", line 1, in
import openpyxl
ImportError: No module named openpyxl
How can this be happening? I know I've installed openpyxl correctly from the Terminal window without any errors so how can my script not find the module?
Try to do:
pip3 install --user openpyxl
Doing the --user worked for me when I tried to run my .py files with matplot lib modules which worked in 3.5 but not in 3.6.
I have the same problem.
I've installed the openpyxl succesfully via Anaconda
!pip3 install --upgrade openpyxl
Collecting openpyxl Using cached
https://files.pythonhosted.org/packages/95/8c/83563c60489954e5b80f9e2596b93a68e1ac4e4a730deb1aae632066d704/openpyxl-3.0.3.tar.gz
Requirement already satisfied, skipping upgrade: jdcal in
/Users/a18301335/Library/Python/3.8/lib/python/site-packages (from
openpyxl) (1.4.1) Requirement already satisfied, skipping upgrade:
et_xmlfile in
/Users/a18301335/Library/Python/3.8/lib/python/site-packages (from
openpyxl) (1.0.1) Installing collected packages: openpyxl Found
existing installation: openpyxl 1.8.6
Uninstalling openpyxl-1.8.6:
Successfully uninstalled openpyxl-1.8.6 Running setup.py install for openpyxl ... done Successfully installed openpyxl-3.0.3
But when I try to use tat library I get an error No module named openpyxl
import openpyxl
ModuleNotFoundError: No module named 'openpyxl'
If I try to import openpyxl in Terminal, I don't have the error. What's wrong?
This may be overly simplistic, but I had the same problem. I installed the module successfully but import openpyxl resulted in an error. I needed to close IDLE and start a new session. After that, my import command worked just fine.

Categories