gpt4 book ai didi

python - 导入错误 : No module named 'PIL' ( Python 3. 4.3 , (1, 8, 7, 'final' , 0)

转载 作者:行者123 更新时间:2023-12-04 19:45:16 25 4
gpt4 key购买 nike

我正在尝试运行我 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 runserver
       (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

是您尝试直接在 bash shell 中导入 Image,但您必须在 python shell 中才能导入 Image。

关于python - 导入错误 : No module named 'PIL' ( Python 3. 4.3 , (1, 8, 7, 'final' , 0),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33949003/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com