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?
Related
I have some old code I'm trying to use which uses httplib2 Python lib. The same exact code works fine on Linux (e.g. Raspberry Pi).
I have used pip to uninstall the httplib2 lib and pip3 to re-install.
Here's what "pip list" (or "pip3 list") shows:
C:\Users\g7847>pip list
Package Version
----------------------- ---------
bcrypt 3.2.0
cachetools 4.2.4
certifi 2021.5.30
cffi 1.15.0
chardet 4.0.0
cryptography 36.0.0
cycler 0.10.0
google-auth 2.3.3
google-auth-httplib2 0.1.0
httplib2 0.20.2
idna 2.10
kiwisolver 1.3.1
matplotlib 3.4.2
numpy 1.21.0
paramiko 2.8.1
Pillow 8.3.1
pip 21.3.1
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycparser 2.21
PyNaCl 1.4.0
pyparsing 2.4.7
python-dateutil 2.8.2
requests 2.25.1
requests-http-signature 0.2.0
rsa 4.8
setuptools 57.1.0
six 1.16.0
urllib3 1.26.6
wheel 0.36.2
C:\Users\g7847>
and yet:
C:\Users\g7847>python3 sshConnect.py
Traceback (most recent call last):
File "C:\Users\g7847\sshConnect.py", line 12, in <module>
import httplib2
ModuleNotFoundError: No module named 'httplib2 '
This is the import section at the beginning. The only library that is complained about is httlib2.
import json
import time
import subprocess
import datetime
import base64
import sys
import os
import getpass
import errno
import re
import string
import httplib2
pip and pip3 are not the same.
pip will use one of your Python versions depending on what exactly is first in the system PATH variable, whereas with pip3 you can be sure that the module will be installed in python3 library.
So, could you double check if the module is actually installed in the python3 library ?
If the module really is installed in python3 library, you could check if the PATH variable is correct.
(You can check the PATH by using the following : Reference)
The httplib2 library is part of the standard library in Python 3.
import httplib ImportError: No module named httplib
is it installed on version 2.x?
pip2 install httplib2
I still don't really know what was going on. I decided for other reasons to switch to the requests library rather than httplib2. My program runs OK inside Idle and I also made Windows EXE of it using pyinstaller on the command line. I thought I was having trouble running it directly as a Python program but I just checked it and it's fine.
One thing that MIGHT have been an issue is that I also have been using WSL (Ubuntu) in Windows and had installed httplib2 over there. I really don't know. I did uninstall that just in case but I'm not using httplib2 any more anyway.
There is a weird issue that happens if you run the Windows 3.9 installer from Python.org. If you subsequently try to run Python, then the Windows Store opens and you can't do anything except install that. So I uninstalled and reinstalled everything a few times but the last time it was just the Windows Store version as it seemed fairly insistent.
I used to code in Jupyter notebook and importing pandas was never thrown an error. But when I use the same code in Visual Studio Code,
# Import Libraries
from random import seed
from random import randint
import pandas
import numpy
import math
import random
import collections
import itertools
import collections
import matplotlib.pyplot as plt
import seaborn as sns
# %matplotlib inline
I receive the below error.
File "g:/My Drive/M/importlibrary.py", line 5, in <module>
import pandas
File "C:\Users\M\Anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
I try to search for several similar issues and most of the solution ask to first uninstall and then install NumPy and Pandas using the below code,
pip3 uninstall pandas
pip3 uninstall numpy
However, I have followed this workaround but the problem did not resolve. The version of python that I am using is,
Python 3.6.8 :: Anaconda, Inc.
Please help if you can.
Is there a reason why you don't install Numpy/Pandas using anaconda (conda install -c anaconda numpy/pandas)? Did you run Jupyter from inside anaconda when it worked? I suggest going to terminal and figuring out where your modules are installed (i.e. if they are inside the anaconda folders, or somewhere where anaconda has access to).
In general, I'd advise against installing python packages for anaconda using pip, just use conda's package manager if you can. This question seems related. In your case, have you tried uninstalling the pip variant and reinstalling using conda?
The problem is resolved by uninstalling the Anaconda. I checked the control panel of the PC and found that there are multiple instances of python. VS Code uses Python 3.6.8 while Anaconda uses python 3.8. So, I uninstall 3.8, and then reinstall pandas,
pip3 uninstall pandas
pip3 install pandas
The error is no more.
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
I get this error while running a keras code, so keras is trying to import
from PIL import Image as pil_image
I have installed pillow, also I'm able to successfully import this in my python terminal but in jupyter notebook it gives import error.
env - ubuntu 16 on aws ec2 instance, I'm using aws deep learning ami for ubuntu
pillow comes with conda, I also tried to install using pip
but again I can import it in python/ipython shell but not in jupyter notebook.
I had opencv installed. But I just installed pillow(keeping opencv) and it worked for me.
So, It seems pillow/pil was included in jesper or opencv package on jupyter notebook, so I uninstalled both jesper and opencv in package portal of notebook and installed pillow. now everything is running fine.
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