Reputation: 1815
New in python and getting few errors while importing image packages. I need to use Pillow package in python. Following packages are already installed in machine:
and
Following is folder structure of C:\Python27\Lib:
still getting error(PIL Package not found) while using following statement:
from PIL import Image
Same error with following:
import Image
already tried:
and rest.
I also observed, when open command line enter python and then place below command, its not giving error. I dont know what does it mean by: Thanks for reading !
Upvotes: 1
Views: 1281
Reputation: 2492
Python2.x and Python3.x use separate site-packages
.
See also what is site-packages
On Linux...
$ python -m site
sys.path = [
'/home/<username>',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
]
USER_BASE: '/home/<username>/.local' (exists)
USER_SITE: '/home/<username>/.local/lib/python2.7/site-packages' (doesn't exist)
ENABLE_USER_SITE: True
$ python3 -m site
sys.path = [
'/home/<username>',
'/usr/lib/python36.zip',
'/usr/lib/python3.6',
'/usr/lib/python3.6/lib-dynload',
'/home/<username>/.local/lib/python3.6/site-packages',
'/usr/local/lib/python3.6/dist-packages',
'/usr/lib/python3/dist-packages',
'/usr/lib/python3.6/dist-packages',
]
USER_BASE: '/home/<username>/.local' (exists)
USER_SITE: '/home/<username>/.local/lib/python3.6/site-packages' (exists)
ENABLE_USER_SITE: True
On Windows, the paths are usually something like...
'C:\\Python27\\lib\\site-packages'
'C:\\Python36\\lib\\site-packages'
If you want to use PIL
in both versions (2.7.16 and 3.7.4) you need to install the Pillow
package into each. I.e.
pip install Pillow
pip3 install Pillow
Upvotes: 3