ImportError: No module named 'PIL' ( Python 3.4.3 , (1, 8, 7, 'final', 0)
ImportError: No module named 'PIL' ( Python 3.4.3 , (1, 8, 7, 'final', 0)
我正在尝试 运行 我 1 年前制作的应用程序,但我似乎无法让它工作。
我运行在基于 CentOS 的 Amazon Linux AMI 下安装它。
>>> import django
>>> django.VERSION
(1, 8, 7, 'final', 0)
(eb_django_app)[ec2-user@ip- mysite]$ python
Python 3.4.3 (default, Apr 1 2015, 18:10:40)
这是错误信息。当我 运行 python manage.py 运行server
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ python manage.py runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f07e8fdbbf8>
Traceback (most recent call last):
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/core/management/commands/runserver.py", line 107, in inner_run
autoreload.raise_last_exception()
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/utils/autoreload.py", line 252, in raise_last_exception
six.reraise(*_exception)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/tmp/eb_django_app/lib64/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/ec2-user/Python-3.4.3/eb_django_app/mysite/pet/models.py", line 6, in <module>
from PIL import Image as img
ImportError: No module named 'PIL'
^C(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ python --version
Python 3.4.3
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ ^C
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ import django
-bash: import: command not found
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ python
Python 3.4.3 (default, Apr 1 2015, 18:10:40)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 8, 7, 'final', 0)
>>>
KeyboardInterrupt
>>> exit()
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ python manage.py runserver^C
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ ^C
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ python manage.py runserver Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f4e85362bf8>
Traceback (most recent call last):
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/core/management/commands/runserver.py", line 107, in inner_run
autoreload.raise_last_exception()
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/utils/autoreload.py", line 252, in raise_last_exception
six.reraise(*_exception)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/tmp/eb_django_app/lib64/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/ec2-user/Python-3.4.3/eb_django_app/mysite/pet/models.py", line 6, in <module>
from PIL import Image as img
ImportError: No module named 'PIL'
这是我尝试安装 pip install PIL 时发生的情况
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ pip install PIL Collecting PIL
Could not find a version that satisfies the requirement PIL (from versions: )
Some externally hosted files were ignored as access to them may be unreliable (use --allow-external PIL to allow).
No matching distribution found for PIL
这是我尝试安装 pip install Pillow 时发生的情况
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ pip install Pillow Collecting Pillow
Using cached Pillow-3.0.0.tar.gz
Installing collected packages: Pillow
Running setup.py install for Pillow
Complete output from command /tmp/eb_django_app/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build- xa9ll2i4/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-hlq0ym7w-record/install-record.txt --single-version-externally-managed --compile --install- headers /tmp/eb_django_app/include/site/python3.4/Pillow:
Single threaded build, not installing mp_compile:1 processes
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/PIL
copying PIL/PcxImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/MspImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GbrImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageDraw2.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GdImageFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/McIdasImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/WalImageFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageChops.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/MpegImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/IptcImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/FontFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/MpoImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PixarImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/BufrStubImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageOps.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/DcxImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageStat.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageMath.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageMode.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/_binary.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/features.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/OleFileIO.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageSequence.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GifImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageShow.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageDraw.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImtImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageQt.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageFont.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageTk.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GimpGradientFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/_util.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PaletteFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImagePath.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageFilter.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/FitsStubImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageCms.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/TgaImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/MicImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageGrab.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/IcoImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageMorph.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/BdfFontFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PalmImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/WmfImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PpmImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ExifTags.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/TiffImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PsdImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/TarIO.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/SpiderImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageColor.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/EpsImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/JpegPresets.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GimpPaletteFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/TiffTags.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/Image.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/XpmImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageEnhance.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageTransform.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/IcnsImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/XVThumbImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PdfImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/WebPImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/XbmImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/FpxImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageWin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/BmpImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PcdImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/__init__.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/Hdf5StubImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PyAccess.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/SgiImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PngImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PcfFontFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GribStubImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImagePalette.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/JpegImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/CurImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/FliImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PSDraw.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ContainerIO.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/Jpeg2KImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/SunImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
running egg_info
writing Pillow.egg-info/PKG-INFO
writing top-level names to Pillow.egg-info/top_level.txt
writing dependency_links to Pillow.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'Pillow.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'Pillow.egg-info/SOURCES.txt'
copying PIL/OleFileIO-README.md -> build/lib.linux-x86_64-3.4/PIL
running build_ext
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-xa9ll2i4/Pillow/setup.py", line 767, in <module>
zip_safe=not debug_build(),
File "/usr/lib64/python3.4/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib64/python3.4/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib64/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/usr/lib64/python3.4/distutils/command/install.py", line 587, in run
self.run_command('build')
File "/usr/lib64/python3.4/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib64/python3.4/distutils/command/build.py", line 126, in run
self.run_command(cmd_name)
File "/usr/lib64/python3.4/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib64/python3.4/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/tmp/pip-build-xa9ll2i4/Pillow/setup.py", line 515, in build_extensions
% (f, f))
ValueError: --enable-jpeg requested but jpeg not found, aborting.
----------------------------------------
Command "/tmp/eb_django_app/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build- xa9ll2i4/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-hlq0ym7w-record/install-record.txt --single-version-externally-managed --compile --install- headers /tmp/eb_django_app/include/site/python3.4/Pillow" failed with error code 1 in /tmp/pip-build-xa9ll2i4/Pillow
python
>>> from PIL import Image as img
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'PIL'
更新:
这是我在尝试安装枕头时收到的错误消息
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ pip install pillow
Collecting pillow
Using cached Pillow-3.0.0.tar.gz
Installing collected packages: pillow
Running setup.py install for pillow
Complete output from command /tmp/eb_django_app/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-abwsqj8g/pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-5akg2zf0-record/install-record.txt --single-version-externally-managed --compile --install-headers /tmp/eb_django_app/include/site/python3.4/pillow:
Single threaded build, not installing mp_compile:1 processes
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/PIL
copying PIL/PcxImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/MspImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GbrImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageDraw2.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GdImageFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/McIdasImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/WalImageFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageChops.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/MpegImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/IptcImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/FontFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/MpoImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PixarImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/BufrStubImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageOps.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/DcxImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageStat.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageMath.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageMode.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/_binary.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/features.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/OleFileIO.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageSequence.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GifImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageShow.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageDraw.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImtImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageQt.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageFont.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageTk.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GimpGradientFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/_util.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PaletteFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImagePath.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageFilter.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/FitsStubImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageCms.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/TgaImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/MicImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageGrab.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/IcoImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageMorph.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/BdfFontFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PalmImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/WmfImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PpmImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ExifTags.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/TiffImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PsdImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/TarIO.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/SpiderImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageColor.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/EpsImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/JpegPresets.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GimpPaletteFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/TiffTags.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/Image.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/XpmImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageEnhance.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageTransform.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/IcnsImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/XVThumbImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PdfImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/WebPImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/XbmImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/FpxImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageWin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/BmpImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PcdImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/__init__.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/Hdf5StubImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PyAccess.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/SgiImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PngImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PcfFontFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GribStubImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImagePalette.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/JpegImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/CurImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/FliImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PSDraw.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ContainerIO.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/Jpeg2KImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/SunImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
running egg_info
writing dependency_links to Pillow.egg-info/dependency_links.txt
writing Pillow.egg-info/PKG-INFO
writing top-level names to Pillow.egg-info/top_level.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'Pillow.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'Pillow.egg-info/SOURCES.txt'
copying PIL/OleFileIO-README.md -> build/lib.linux-x86_64-3.4/PIL
running build_ext
building 'PIL._imaging' extension
creating build/temp.linux-x86_64-3.4/libImaging
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DHAVE_LIBJPEG -DHAVE_LIBZ -I/tmp/pip-build-abwsqj8g/pillow/libImaging -I/tmp/eb_django_app/include -I/usr/local/include -I/usr/include -I/usr/include/python3.4m -c _imaging.c -o build/temp.linux-x86_64-3.4/_imaging.o
_imaging.c:76:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/tmp/eb_django_app/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-abwsqj8g/pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-5akg2zf0-record/install-record.txt --single-version-externally-managed --compile --install-headers /tmp/eb_django_app/include/site/python3.4/pillow" failed with error code 1 in /tmp/pip-build-abwsqj8g/pillow
您必须安装 libjpeg-devel 包。
在 Amazon Linux AMI 下(您在评论中提到的您正在使用的):
sudo yum install libjpeg-devel
安装后您可能仍然会遇到错误。
如果出现错误:
ValueError: --enable-zlib requested but zlib not found, aborting.
安装 zlib-devel 包:
sudo yum install zlib-devel
如果出现错误:
error: command 'gcc' failed with exit status 1
运行:
sudo yum install gcc gcc-c++
安装 gcc
如果仍有问题,请尝试安装软件包:
sudo yum install python-devel
我今天从 GCE 切换到 EC2(Amazon Linux AMI 也是),在尝试安装 Pillow 时遇到了这些错误。安装这些包后安装没问题。
您遇到的问题
eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ import Image as img
-bash: import: command not found
您是想直接在bashshell中导入Image,但是您必须在pythonshell中导入Image。
我正在尝试 运行 我 1 年前制作的应用程序,但我似乎无法让它工作。
我运行在基于 CentOS 的 Amazon Linux AMI 下安装它。
>>> import django
>>> django.VERSION
(1, 8, 7, 'final', 0)
(eb_django_app)[ec2-user@ip- mysite]$ python
Python 3.4.3 (default, Apr 1 2015, 18:10:40)
这是错误信息。当我 运行 python manage.py 运行server
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ python manage.py runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f07e8fdbbf8>
Traceback (most recent call last):
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/core/management/commands/runserver.py", line 107, in inner_run
autoreload.raise_last_exception()
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/utils/autoreload.py", line 252, in raise_last_exception
six.reraise(*_exception)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/tmp/eb_django_app/lib64/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/ec2-user/Python-3.4.3/eb_django_app/mysite/pet/models.py", line 6, in <module>
from PIL import Image as img
ImportError: No module named 'PIL'
^C(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ python --version
Python 3.4.3
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ ^C
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ import django
-bash: import: command not found
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ python
Python 3.4.3 (default, Apr 1 2015, 18:10:40)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 8, 7, 'final', 0)
>>>
KeyboardInterrupt
>>> exit()
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ python manage.py runserver^C
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ ^C
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ python manage.py runserver Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f4e85362bf8>
Traceback (most recent call last):
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/core/management/commands/runserver.py", line 107, in inner_run
autoreload.raise_last_exception()
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/utils/autoreload.py", line 252, in raise_last_exception
six.reraise(*_exception)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/tmp/eb_django_app/lib64/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/ec2-user/Python-3.4.3/eb_django_app/mysite/pet/models.py", line 6, in <module>
from PIL import Image as img
ImportError: No module named 'PIL'
这是我尝试安装 pip install PIL 时发生的情况
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ pip install PIL Collecting PIL
Could not find a version that satisfies the requirement PIL (from versions: )
Some externally hosted files were ignored as access to them may be unreliable (use --allow-external PIL to allow).
No matching distribution found for PIL
这是我尝试安装 pip install Pillow 时发生的情况
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ pip install Pillow Collecting Pillow
Using cached Pillow-3.0.0.tar.gz
Installing collected packages: Pillow
Running setup.py install for Pillow
Complete output from command /tmp/eb_django_app/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build- xa9ll2i4/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-hlq0ym7w-record/install-record.txt --single-version-externally-managed --compile --install- headers /tmp/eb_django_app/include/site/python3.4/Pillow:
Single threaded build, not installing mp_compile:1 processes
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/PIL
copying PIL/PcxImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/MspImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GbrImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageDraw2.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GdImageFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/McIdasImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/WalImageFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageChops.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/MpegImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/IptcImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/FontFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/MpoImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PixarImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/BufrStubImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageOps.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/DcxImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageStat.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageMath.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageMode.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/_binary.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/features.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/OleFileIO.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageSequence.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GifImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageShow.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageDraw.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImtImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageQt.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageFont.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageTk.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GimpGradientFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/_util.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PaletteFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImagePath.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageFilter.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/FitsStubImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageCms.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/TgaImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/MicImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageGrab.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/IcoImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageMorph.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/BdfFontFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PalmImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/WmfImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PpmImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ExifTags.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/TiffImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PsdImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/TarIO.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/SpiderImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageColor.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/EpsImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/JpegPresets.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GimpPaletteFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/TiffTags.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/Image.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/XpmImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageEnhance.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageTransform.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/IcnsImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/XVThumbImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PdfImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/WebPImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/XbmImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/FpxImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageWin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/BmpImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PcdImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/__init__.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/Hdf5StubImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PyAccess.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/SgiImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PngImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PcfFontFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GribStubImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImagePalette.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/JpegImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/CurImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/FliImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PSDraw.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ContainerIO.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/Jpeg2KImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/SunImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
running egg_info
writing Pillow.egg-info/PKG-INFO
writing top-level names to Pillow.egg-info/top_level.txt
writing dependency_links to Pillow.egg-info/dependency_links.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'Pillow.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'Pillow.egg-info/SOURCES.txt'
copying PIL/OleFileIO-README.md -> build/lib.linux-x86_64-3.4/PIL
running build_ext
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-xa9ll2i4/Pillow/setup.py", line 767, in <module>
zip_safe=not debug_build(),
File "/usr/lib64/python3.4/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib64/python3.4/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib64/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/eb_django_app/local/lib/python3.4/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/usr/lib64/python3.4/distutils/command/install.py", line 587, in run
self.run_command('build')
File "/usr/lib64/python3.4/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib64/python3.4/distutils/command/build.py", line 126, in run
self.run_command(cmd_name)
File "/usr/lib64/python3.4/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.4/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib64/python3.4/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/tmp/pip-build-xa9ll2i4/Pillow/setup.py", line 515, in build_extensions
% (f, f))
ValueError: --enable-jpeg requested but jpeg not found, aborting.
----------------------------------------
Command "/tmp/eb_django_app/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build- xa9ll2i4/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-hlq0ym7w-record/install-record.txt --single-version-externally-managed --compile --install- headers /tmp/eb_django_app/include/site/python3.4/Pillow" failed with error code 1 in /tmp/pip-build-xa9ll2i4/Pillow
python
>>> from PIL import Image as img
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'PIL'
更新:
这是我在尝试安装枕头时收到的错误消息
(eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ pip install pillow
Collecting pillow
Using cached Pillow-3.0.0.tar.gz
Installing collected packages: pillow
Running setup.py install for pillow
Complete output from command /tmp/eb_django_app/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-abwsqj8g/pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-5akg2zf0-record/install-record.txt --single-version-externally-managed --compile --install-headers /tmp/eb_django_app/include/site/python3.4/pillow:
Single threaded build, not installing mp_compile:1 processes
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/PIL
copying PIL/PcxImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/MspImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GbrImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageDraw2.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GdImageFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/McIdasImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/WalImageFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageChops.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/MpegImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/IptcImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/FontFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/MpoImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PixarImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/BufrStubImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageOps.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/DcxImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageStat.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageMath.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageMode.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/_binary.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/features.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/OleFileIO.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageSequence.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GifImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageShow.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageDraw.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImtImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageQt.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageFont.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageTk.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GimpGradientFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/_util.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PaletteFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImagePath.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageFilter.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/FitsStubImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageCms.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/TgaImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/MicImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageGrab.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/IcoImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageMorph.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/BdfFontFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PalmImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/WmfImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PpmImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ExifTags.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/TiffImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PsdImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/TarIO.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/SpiderImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageColor.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/EpsImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/JpegPresets.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GimpPaletteFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/TiffTags.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/Image.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/XpmImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageEnhance.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageTransform.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/IcnsImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/XVThumbImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PdfImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/WebPImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/XbmImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/FpxImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImageWin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/BmpImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PcdImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/__init__.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/Hdf5StubImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PyAccess.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/SgiImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PngImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PcfFontFile.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/GribStubImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ImagePalette.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/JpegImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/CurImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/FliImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/PSDraw.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/ContainerIO.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/Jpeg2KImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
copying PIL/SunImagePlugin.py -> build/lib.linux-x86_64-3.4/PIL
running egg_info
writing dependency_links to Pillow.egg-info/dependency_links.txt
writing Pillow.egg-info/PKG-INFO
writing top-level names to Pillow.egg-info/top_level.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'Pillow.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'Pillow.egg-info/SOURCES.txt'
copying PIL/OleFileIO-README.md -> build/lib.linux-x86_64-3.4/PIL
running build_ext
building 'PIL._imaging' extension
creating build/temp.linux-x86_64-3.4/libImaging
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DHAVE_LIBJPEG -DHAVE_LIBZ -I/tmp/pip-build-abwsqj8g/pillow/libImaging -I/tmp/eb_django_app/include -I/usr/local/include -I/usr/include -I/usr/include/python3.4m -c _imaging.c -o build/temp.linux-x86_64-3.4/_imaging.o
_imaging.c:76:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/tmp/eb_django_app/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-abwsqj8g/pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-5akg2zf0-record/install-record.txt --single-version-externally-managed --compile --install-headers /tmp/eb_django_app/include/site/python3.4/pillow" failed with error code 1 in /tmp/pip-build-abwsqj8g/pillow
您必须安装 libjpeg-devel 包。
在 Amazon Linux AMI 下(您在评论中提到的您正在使用的):
sudo yum install libjpeg-devel
安装后您可能仍然会遇到错误。
如果出现错误:
ValueError: --enable-zlib requested but zlib not found, aborting.
安装 zlib-devel 包:
sudo yum install zlib-devel
如果出现错误:
error: command 'gcc' failed with exit status 1
运行:
sudo yum install gcc gcc-c++
安装 gcc
如果仍有问题,请尝试安装软件包:
sudo yum install python-devel
我今天从 GCE 切换到 EC2(Amazon Linux AMI 也是),在尝试安装 Pillow 时遇到了这些错误。安装这些包后安装没问题。
您遇到的问题
eb_django_app)[ec2-user@ip-172-31-11-114 mysite]$ import Image as img
-bash: import: command not found
您是想直接在bashshell中导入Image,但是您必须在pythonshell中导入Image。