2

Elastic Beanstalk で Django バックエンド システムを開発しています。

JPEG 画像ファイルをアップロードすると、エラーが発生しますdecoder jpeg not available。.png 画像ファイルをアップロードしても問題はありません。

バックエンド環境:

  • AWS ビーンズトーク: Python 2.7 を実行する 64 ビット Amazon Linux 2014.03 v1.0.4
  • パイソン: 2.7
  • pip パッケージ一覧 Django==1.6.5 Markdown==2.4.1 MySQL-python==1.2.5 Pillow==2.5.3 boto==2.30.0 django-filter==0.7 django-storages==1.1.8 djangorestframework ==2.3.14 wsgiref==0.1.2

エラーの原因となっているソース コード:

意見

normalImage = NormalImage(image=image, userProfile=request.user.profile, category = category)
normalImage.save()

モデル

class NormalImage(models.Model):
    userProfile = models.ForeignKey(UserProfile)
    height = models.PositiveIntegerField(editable=False)
    width = models.PositiveIntegerField(editable=False)
    image = models.ImageField(upload_to=rename_image_file, width_field='width', height_field='height')
    size = models.TextField()
    price = models.PositiveIntegerField()
    tags = models.ManyToManyField(Tag)
    category = models.ForeignKey(Category)
    created_datetime = models.DateTimeField(auto_now_add=True)

def __init__(self, *args, **kwargs):
    super(NormalImage,self).__init__(*args, **kwargs)
    if not self.id:
        self.size = Size.determineSizeDescription(anWidth=self.width, aHeight=self.height)
        self.price = Size.determinePrice(anWidth=self.width, aHeight=self.height)

def get_created_datetime_str(self):
    return self.created_datetime.strftime('%Y-%m-%d %H:%M:%S')

def get_image_url(self):
    return 'http://photocoapi-env-x2ezvferc7.elasticbeanstalk.com/images/' + str(self.id) + '/'

エラーコード:

/me/requests/ の IOError デコーダー jpeg は利用できません リクエスト方法: GET リクエスト URL:
http://photoco-env-z5cnmns3pe.elasticbeanstalk.com/me/requests/Django バージョン: 1.6.5 例外タイプ: IOError 例外値: デコーダー jpeg は利用できません 例外の場所: /opt/python/run/venv/lib/python2.7/site-packages/PIL/Image.py in _getdecoder、413 行目 Python実行可能ファイル: /opt/python/run/venv/bin/python Python バージョン: 2.7.5 Python パス: ['/opt/python/run/venv/lib/python2.7/site-packages', '/opt/python /current/app'、'/opt/python/bundle/4/app'、'/opt/python/run/baselinenv/lib64/python27.zip'、'/opt/python/run/baselinenv/lib64/python2. 7', '/opt/python/run/baselinenv/lib64/python2.7/plat-linux2', '/opt/python/run/baselinenv/lib64/python2.7/lib-tk', '/opt/python /run/baselinenv/lib64/python2.7/lib-old', '/opt/python/run/baselinenv/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7', '/usr/lib/python2.7', '/opt/python/run/baselinenv/lib/python2.7/site-packages']

この問題を解決するために私が試みたこと:

  • SSH経由でbeanstalkサーバーに接続し、yumを使用して以下のライブラリをインストールしました
  • yum: libjpeg-devel、zlib-devel、freetype-devel

    • そして、シンボリックリンクを作成します

      $ sudo ln -s /usr/lib64/libjpeg.so /usr/lib $ sudo ln -s /usr/lib64/zlib.so /usr/lib $ sudo ln -s /usr/lib64/freetype.so /usr/ライブラリ

4

3 に答える 3

2

必要なすべての依存関係を含む「requirements.txt」というファイルをアプリ ソースに含めると、AWS Elastic Beanstalk が依存関係をインストールします。

ebextensions を使用して yum パッケージをインストールできます。アプリのソースで呼び出されるファイルを作成し.ebextensions/01-yum.config、次の内容を入れます。

packages: 
  yum:
    libjpeg-devel: [] 
    <another-package>: []

このファイルは YAML 形式であるため、インデントが重要です。

ebextensions のパッケージ セクションの詳細については、こちらをご覧ください。

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-packages

これは、Elastic Beanstalk で requirements.txt を使用するためのチュートリアルです。

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_python_console.html

于 2014-09-03T19:09:08.080 に答える
0

JPEG 画像をサポートするための依存関係は、Pillow を pip (画像のデコードに使用される Python ライブラリ) と共にインストールする前にインストールする必要があります。

したがって、次のことを試みる必要があります。

  • 枕をアンインストールします。

    pip uninstall pillow

  • jpeg ライブラリをインストールします

    yum install libjpeg-devel

  • 枕を再インストールします。

    pip install pillow

于 2014-09-03T09:13:42.957 に答える