Module Not Found Error: No module named 'squarify' - python-3.x

On Jupyter notebook, running Python 3 code. Trying to build a squarify Tree map.
When I run the code:
import squarify as sq
ModuleNotFoundError arrises. "No Module named 'squarify'."
Although I know there such a module.
Can someone help me?
I've tried to put
path/to/python -m pip install squarify
and
install squarify
in the cell, but to no avail.
import squarify as sq results in:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-43-d5603c2d6e58> in <module>
6 #Put a title on the chart
7
----> 8 import squarify as sq
9
10 #determine count for each type weathersit
ModuleNotFoundError: No module named 'squarify'

Thank you for all the answers to this question. I have since figured it out. Best advice I can give is to search Anaconda Prompt (Anaconda 3) on your computer, which will pull up a script. Then simply time pip install squarify.
Once this loads the program on your computer, try to import squarify as sq on your jupyter notebook, and the chunk should now work without errors.
Good luck to everyone, and thank you for all the help!
Zach

In my case squarify was added to miniconda - I was not able to import it into anaconda.
I opened Anaconda Navigator - uninstalled miniconda.
Updated anaconda and imported squarify to anaconda (anaconda prompt) and it work now via simple import squarify cmd.

For me I opened Anaconda Navigator, went to Environments base(root) and clicked Open Terminal. I run the below command in the terminal and all was OK.
pip install squarify

Related

Python package pypdf2 is "already installed" but can not import it

I am a newbie with Python and I am going around in circles over python's inability to find a mod. In jupyter notebook here is what I get:
pip install pypdf2
Requirement already satisfied: pypdf2 in c:\users\stanleydenman\appdata\local\programs\python\python311\lib\site-packages (3.0.1)
Note: you may need to restart the kernel to use updated packages.
import pypdf2
import pypdf2
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[2], line 1
----> 1 import pypdf2
ModuleNotFoundError: No module named 'pypdf2
So python acknowledges pypdf2 is installed, but cannot find it to import it? I
I have installed, and reinstalled python. I selected the option once to have environmental variables set, other times set them myself. Nothing makes a difference.
Environmental variable set as follows:
C:\Users\StanleyDenman\AppData\Local\Programs\Python\Python311\Scripts\site-packages;C:\Users\StanleyDenman\AppData\Local\Programs\Python\Python311\;C:\Users\StanleyDenman\AppData\Local\Microsoft\WindowsApps;C:\Users\StanleyDenman\AppData\Roaming\npm;C:\Users\StanleyDenman\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Tesseract-OCR;
Tried with Anaconda, cmd line, and jupyter notebook. All the same result.
Try pip list to make sure it's installed.

Numpy not recognized even though it is installed

VSCode, Python3.8.4 64-bit, first assignment with Jupyter notebooks. I have installed numpy but when I run import numpy as np I receive ModuleNotFoundError: No module named 'numpy'. I'm very new please be gentle.
Write pip list in anaconda prompt or cmd and search for it if you don t find it then it s a problem of path
I don't know why this worked but I changed my python interpreter in VSCode to 3.8.5 and now I'm all good.

Installing opencv 3.4.2 with Anaconda

I'm running Ubuntu 18.04LTS:
Firstly, I couldn't install opencv from anaconda on my existing environment (base) as it kept searching for conflicts forever and then getting stuck with an empty window saying "these packages will be modified" while displaying absolutely nothing and with the only choice of pressing the "cancel" button.
I created a new virtual environment named env_opencv and was able to install opencv:
enter image description here
Then, I run a jupyter notebook that imports opencv:
import cv2
import matplotlib.pyplot as plt
import matplotlib.patches as patches
...
And here's what I get:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-8-31cd2c78c525> in <module>
----> 1 import cv2
2 import matplotlib.pyplot as plt
3 import matplotlib.patches as patches
4
5 from align import AlignDlib
ModuleNotFoundError: No module named 'cv2'
No matter what I tried, including reinstalling opencv directly from the conda prompt, I can't get past this error.
Incidentally, I was able to make it work on Windows 10 going through the Anaconda prompt and using conda. However, my Windows machine doesn't have an nVidia GPU and I can't use it for CNN training, so I really need to make it work on Ubuntu.
Any suggestions would be great. Thank you.
I found a workaround to this issue:
I activate the env_opencv environment from the command line, then I launch jupyter notebook and it works.
Maybe, there is a bug with anaconda-navigator that doesn't seem to switch environments from the GUI?

Jupyter Notebook can't find module

Hi I have been trying to install twython for Jupyter Notebook. I have proved through the python repl that it is universally installed throughout my laptop. But it still won't appear on Jupyter Notebook. Looking for help trying to figure out it is found in a spot that it can be found by my Anaconda 3 Jupyter Notebook.
Context: Homework assignment trying to mine twitter for tweets
Here is the errors I am receiving and I am running Mac OS
/Users/name/twitter/__init__.py:22: UserWarning: The twython library has not been installed. Some functionality from the twitter package will not be available.
"The twython library has not been installed. "
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-4-38297a1141e0> in <module>
----> 1 import twitter
2 import twython
3 #---------------------------------------------
4 # Define a Function to Login Twitter API
5 def oauth_login():
~/twitter/__init__.py in <module>
34
35
---> 36 from nltk.twitter.common import json2csv
ModuleNotFoundError: No module named 'nltk.twitter
Have you installed nltk package?
If not, do it:
pip3 install -U nltk
then run python3
inside python3 command line, run:
import nltk
nltk.download()
after the download, restart jupyter, and run your code again.

Jupyter Notebook Packages Won't Import

I've searched around for a while, and I've tried many things such as
conda create -n ipykernel_py3 python=3 ipykernel
source activate ipykernel_py3 # On Windows, remove the word 'source'
python -m ipykernel install --user
Uninstalling and reinstall both Python3 and Anaconda3. All I want is for Jupyter Notebook to be able to use libraries in Anaconda. If I change my environment to root via
activate root
I can open Jupyter notebook, however when I do
activate ipykernel_py3
and then try to do
jupyter notebook
I get the error
Error executing Jupyter command 'notebook': [Errno 'jupyter-notebook' not found] 2
When I open Jupyter notebook and input
import os
os.getcwd()
I get
'C:\Users\Mike\Documents\Mathematical Modeling'
and Anaconda is in
'C:\ProgramData\Anaconda3'
The problem is when I do
import numpy
I get this error
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-5a0bd626bb1d> in <module>()
----> 1 import numpy
ModuleNotFoundError: No module named 'numpy'
--------------------------------------EDIT--------------------------------------
I've just uninstalled anaconda, and am currently reinstalling it. For some reason I was unable to install other packages to my ipykernel_py3 environment. Hopefully I figure something out.
The solution after countless re-installations of anaconda, and working with environments, is this
Go to start menu->
View Advanced System Settings->Environment Variables
highlight the variable that has name 'Path'
Click edit
Change variable value to 'C:\Users\Mike\Anaconda3\Scripts'
Of course my directory will be different from anyone else's, but this solved all my problems.

Resources