2016-08-11 18 views
1

私は2日間このエラーに苦しんでいますが、スタックオーバーフローからすべての回答を試みましたが、運はありませんでした。私は、管理者からのモデルにアクセスしていたときに、運用サーバーではDjangoの画像フィールドImportError:名前をインポートできません_imaging Django Admin Pillowからのアクセス

class Author(models.Model): 
    first_name = models.CharField(max_length=30) 
    last_name = models.CharField(max_length=30) 
    email = models.EmailField() 
    url = models.URLField(blank=True, null=True) 
    short_bio = models.TextField(max_length=200, blank=True, null=True) 
    long_bio = models.TextField(max_length=5000, blank=True, null=True) 
    role = models.ManyToManyField(AuthorRole) 
    facebook_link = models.URLField(blank=True, null=True) 
    linkedin_link = models.URLField(blank=True, null=True) 
    twitter_link = models.URLField(blank=True, null=True) 
    gplus_link = models.URLField(blank=True, null=True) 
    thumbnail = models.ImageField(upload_to='images/',  default='images/user_default.jpg') 

を使用し、画像を選択し、その次のエラーを投げて、保存しようと、単純なモデルを持っています。私は枕を何度か取り付けてアンインストールしました。 djangoと枕の別のバージョンを試してみました。ちなみに、ローカル環境では正常に動作します。

[:error] [pid 20256:tid 139822013380352] [remote 72.48.102.12:60881] 
from PIL import Image 
[:error] [pid 20256:tid 139822013380352] [remote 72.48.102.12:60881]  File"/home/.virtualenvs/wcsenvpython3/lib/python3.4/sitepackages/PIL/Image.py", line 67, in <module> 
[:error] [pid 20256:tid 139822013380352] [remote 72.48.102.12:60881] 
from PIL import _imaging as core 
[:error] [pid 20256:tid 139822013380352] [remote 72.48.102.12:60881] ImportError:cannot import name _imaging 

from PIL import _imaging manage.pyからpythonpathが適切に設定されているようです。 enter image description here

私のvirtualenvの中に_imaging.cpython-34m.soファイルがありますが、 _imaging.pyファイルはありません。 enter image description here

私のサーバーはlinodeでホストされています。それはUbuntu 14.04です。私はApache2を使用しています。 Python 3.4.3。 Django 1.10ピロー3.3.0。あなたの親切な助けはとても感謝しています。このエラーは長い間私を悩ませています。

1http://i.stack.imgur.com/nH8O3.jpg2http://i.stack.imgur.com/Vpdoe.jpg

+0

枕を再インストールするために使用したコマンドは何ですか? –

+0

ピペットをはずし、ピローを取り付けます。お返事をありがとうございます。私は答えを見つけた。下の私の答えをチェックしてください。 –

答えて

1

さてさて、私は最後に答えを得ました。それはピローとは関係ありません。私は画像が保存されている突然それが問題を解決した 'メディア'フォルダに公共の書き込み許可を与えた。セキュリティ上の脆弱性かどうかはわかりませんが、このエラーは解決します。

は、どのように私はそれを見つけた:
私はPILからImage.pyファイルを変更することを決めました。

try: 
    # If the _imaging C module is not present, Pillow will not load. 
    # Note that other modules should not refer to _imaging directly; 
    # import Image and use the Image.core variable instead. 
    # Also note that Image.core is not a publicly documented interface, 
    # and should be considered private and subject to change. 
    from PIL import _imaging as core 
    if PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None): 
     raise ImportError("The _imaging extension was built for another " 
          " version of Pillow or PIL") 

except ImportError as v: 
    core = _imaging_not_installed() 
    # Explanations for ways that we know we might have an import error 
    if str(v).startswith("Module use of python"): 
     # The _imaging C module is present, but not compiled for 
     # the right version (windows only). Print a warning, if 
     # possible. 
     warnings.warn(
      "The _imaging extension was built for another version " 
      "of Python.", 
      RuntimeWarning 
      ) 
    elif str(v).startswith("The _imaging extension"): 
     warnings.warn(str(v), RuntimeWarning) 
    elif "Symbol not found: _PyUnicodeUCS2_" in str(v): 
     # should match _PyUnicodeUCS2_FromString and 
     # _PyUnicodeUCS2_AsLatin1String 
     warnings.warn(
      "The _imaging extension was built for Python with UCS2 support; " 
      "recompile Pillow or build Python --without-wide-unicode. ", 
      RuntimeWarning 
      ) 
    elif "Symbol not found: _PyUnicodeUCS4_" in str(v): 
     # should match _PyUnicodeUCS4_FromString and 
     # _PyUnicodeUCS4_AsLatin1String 
     warnings.warn(
      "The _imaging extension was built for Python with UCS4 support; " 
      "recompile Pillow or build Python --with-wide-unicode. ", 
      RuntimeWarning 
      ) 
    # Fail here anyway. Don't let people run with a mostly broken Pillow. 
    # see docs/porting.rst 
    raise 

exceptブロックはいくつかの条件をチェックしており、最後の行でインポートエラーが再び発生しています。私はraiseとコメントし、ビンゴは私に許可エラーを示しました。 問題が許可されている間に、なぜ地球にインポートエラーが表示されるのか分かりません。私は枕の作家が問題を見て、問題が実際にはエラーではなくアクセスエラーであるのに対し、関連するエラーメッセージを生成しようとします。

関連する問題