Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8300485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:34:31+00:00 2026-06-08T16:34:31+00:00

I am running Django 1.4 and PIL 1.1.7 in a virtualenv managed with pip

  • 0

I am running Django 1.4 and PIL 1.1.7 in a virtualenv managed with pip. Whenever I upload a JPEG file via my admin interface, I get the following error: Upload a valid image. The file you uploaded was either not an image or a corrupted image.

As many Ubuntu users have reported, on installation, PIL erronously looked in /usr/lib/ for libjpeg, while its true location was in /usr/lib/i386-linux-gnu/. That’s taken care of; I followed the answers in these posts:

Django ImageField "Upload a valid image. The file you uploaded was either not an image or a corrupted image."

Why can't I upload jpg files to my Django app via admin/?

Now the final output of installation looks as follows:


PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version       1.1.7
platform      linux2 2.7.3 (default, Apr 20 2012, 22:44:07)
              [GCC 4.6.3]
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.

To check the build, run the selftest.py script.
changing mode of build/scripts-2.7/pilfile.py from 644 to 755
changing mode of build/scripts-2.7/pilfont.py from 644 to 755
changing mode of build/scripts-2.7/pilconvert.py from 644 to 755
changing mode of build/scripts-2.7/pilprint.py from 644 to 755
changing mode of build/scripts-2.7/pildriver.py from 644 to 755

changing mode of /usr/local/bin/pilfile.py to 755
changing mode of /usr/local/bin/pilfont.py to 755
changing mode of /usr/local/bin/pilconvert.py to 755
changing mode of /usr/local/bin/pilprint.py to 755
changing mode of /usr/local/bin/pildriver.py to 755
Successfully installed PIL

However, Django still doesn’t allow me to upload anything but BMP files, which is not acceptable for this project. Unlike the user in the second link, I’m not using Apache, so my problem is probably not related. My suspicion is that Django is still using an old installation of PIL. The problem is that I don’t know where it could be getting it from. The files in ~/.virtualenvs/project/local/lib/python2.7/site-packages seem up-to-date to me. Any ideas?

EDIT 1: Also note that I have tried logging out and logging back in the admin, as well as installing pillow, as in this post: Uploading a JPEG image via Django displays error

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T16:34:33+00:00Added an answer on June 8, 2026 at 4:34 pm

    It turns out that this whole thing is my fault due to a misunderstanding of how pip actually works. By habit, I associate any and all installations with superuser privileges, which was not only not necessary in this case, but a recipe for confusion.

    The first time I installed PIL, I did not prefix it with sudo, but I did each time after. Thus, building from Meitham’s advice, I checked to see where the import was coming from. It came from the correct place, but it did not have the extensions I desired, despite the post-installation output saying I did. Long story short, I removed the directory from my site-packages, then pip freeze continued to tell me I did not have PIL but sudo pip install told me I did.

    Lesson learned: virtualenv is based in the user’s directory, on the user’s privileges. Think twice before combining sudo and pip in the same command.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when running django-admin.py makemessages -l fa based on internationalization documentations in windows i get
I am running Django 1.2.2 and I get the following error when I try
I am running django simple server via manage.py runserver. With a client code I
I have Django running in Apache via mod_wsgi. I believe Django is caching my
I am trying to get django to show pictures. Ive installed PIL and it
I am trying to get django-registration up and running on my newbie setup on
I'm running Django as threaded fastcgi via flup, served by lighttpd, communicating via sockets.
while running django tests with selenium (no remote, no xvfb), I always get the
After running django-admin.py makemessages -l de in Django to create the translation files, you
I am running django server and when I do a post I get a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.