Library installed and shown in conda, but not usable in Jupyter Notebook - python-3.x

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

Related

How to import in python 3?

I am self-learning Python and all the online courses use labs where all libraries are already imported. Whenever I try to import numpy or pandas or any other library I receive this message:
"Traceback (most recent call last):
File "<pyshell#6>", line 1, in
import numpy as np
ModuleNotFoundError: No module named 'numpy'"
What am I doing wrong?
import-error-no-module-named-numpy
ModuleNotFoundError is thrown when a module could not be found
Support for Python 3 was added in NumPy version 1.5.0
you do not install numpy Correctly
pip uninstall numpy
pip3 install numpy
I strongly recommend you use Virtualenv to install it numpy
pip install virtualenv
go to folder of your code use
virtualenv venv
//Windows
venv\Scripts\activate
//Linux
source venv/bin/activate
you can use conda to install numpy
download conda from here coda GUI installer
Best practice, use an environment rather than install in the base env
conda create -n my-env
conda activate my-env
If you want to install from conda-forge
conda config --env --add channels conda-forge
The actual install command
conda install numpy

Why I can not import utils in my Jupyter Notebook (Python 3.6) although it is installed?

I have installed the package utils using conda but when I try to import it in my Jupyter Notebook I get an exception:
import utils
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-4-32411ba4e9a6> in <module>()
----> 1 import utils
ModuleNotFoundError: No module named 'utils'
If I try installing again using pip this time I get the expected message:
(base) C:\Users\Alienware\Documents>pip install python-utils
Requirement already satisfied: python-utils in c:\programdata\anaconda3\lib\site-packages (2.3.0)
Requirement already satisfied: six in c:\programdata\anaconda3\lib\site-packages (from python-utils) (1.10.0)
Other modules are imported without any problem (e.g. featuretools).
You have installed python-utils but are importing utils. These are two different packages. If you want to use the utils package, install it with pip install utils. Otherwise, use import python_utils if you want to use that package.

When importing tensorflow, I get the following error: No module named 'numpy.core._multiarray_umath'

I have installed Ancaconda3 and Tensorflow. When I try to import Tensorflow in python shell I receive the following error:
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
ImportError: numpy.core.multiarray failed to import
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "", line 980, in _find_and_load SystemError:
<class '_frozen_importlib._ModuleLockManager'> returned a result with
an error set ImportError: numpy.core._multiarray_umath failed to
import ImportError: numpy.core.umath failed to import
I am not sure what the problem is as numpy is installed on my system and can be successfully imported in python.
I am using Windows10.
I also had the same issue.
It got resloved once I upgraded the numpy from 1.15.4 to 1.16.1.
If you're using pip:
pip install numpy --upgrade
Numpy that came with Anaconda3 is of version 1.15.4. so i upgraded and it worked.
Side note: if you're also using scikit-image in your script, be aware that numpy 1.16.3 has a conflict with old versions of scikit-image (e.g. you may get ImportError: cannot import name '_validate_lengths'). In that case, pip install --upgrade scikit-image from terminal solved the issue for me.
Kindly check whether you have installed the numpy package from pip. Because if you are running on conda evironment, then all packages need to be downloaded from there.
Please use the below mentioned statement for this purpose
conda install -c anaconda numpy
Also make sure that the numpy version supports the Python version you are using.
You can use two options in python 3.6
Install
py pip -m install numpy==1.14.5
Upgrade
py pip install numpy --upgrade
Note: the version most recently is 1.14.5
I also had this issue with python 3.8.9 and Numpy 1.24.1.
Downgrading to Numpy 1.21.0 fixed the issue.

Problem with importing Image from PIL in python

import PIL
from PIL import Image
THE ERROR SHOWN IS :
ImportError: The _imaging extension was built for another version of Pillow
or
PIL:
Core version: 3.0.0
Pillow version: 5.1.0
I am running this on jupyter notebook on anaconda. I tried installing pillow through both pip and conda and I am still not able import the mentioned package. Am I missing out on any fundamental thing over here?

Problems installing PyGame into my Anaconda copy of Python on my macbook pro [duplicate]

So, I have installed Anaconda3 64 bit and TensorFlow, matplotlib, and I have also installed pygame, but I still got an error saying ModuleNotFoundError: No module named 'pygame' and ModuleNotFoundError: No module named 'pygame'
In Anaconda, I have made a new environment and that has all of the packages I have installed and I open jupyter notebook from this environment. Still the error is there.
In Anaconda command prompt:
(base) C:\Users\Eszter>pip install pygame
Requirement already satisfied: pygame in c:\users\eszter\anaconda3\lib\site-packages (2.0.1)
Part of the code is this:
**
import numpy as np
import matplotlib.pyplot as plt
import pygame
from agent import Agent
**
No module named 'pygame'
No module named 'agent'
Anybody can help me with this? I really appreciated it.
Use conda install from anaconda prompt instead of pip
conda install pygame

Resources