469,277 Members | 2,357 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,277 developers. It's quick & easy.

just want to open a simple window keep getting this error

Traceback (most recent call last):
File "C:/Users/Brad/Desktop/python programs/window.py", line 5, in <module>
window.save('window.png')
File "C:\Python31\lib\site-packages\PIL\Image.py", line 1421, in save
preinit()
File "C:\Python31\lib\site-packages\PIL\Image.py", line 281, in preinit
from . import BmpImagePlugin
ValueError: Attempted relative import in non-package

heres the code, im running windows 7 32bit and have the (PIL) downloded as well as pygame

Expand|Select|Wrap|Line Numbers
  1. from Image import *
  2.  
  3. window = new('RGB',(200,200),255)
  4.  
  5. window.save('window.png')
Jun 4 '11 #1
3 2124
bvdet
2,851 Expert Mod 2GB
Try this:
Expand|Select|Wrap|Line Numbers
  1. from PIL import Image
  2. window = Image.new('RGB',(200,200),255)
  3. window.save('window.png')
Jun 6 '11 #2
That raises a sytactical error, as the PIL is not directly recfferanced in such a way. Its called as Image, also in the newer versions(sence like 2.7.1) moduals like ImageDraw have to be called sepprately. But I've figured this isue out and have some others I'm deali7ng with now lol. Thanx for the reply though
Jun 7 '11 #3
bvdet
2,851 Expert Mod 2GB
There was a missing closing parenthesis. Otherwise the syntax was correct. This works on my system. Please post back your solution.

Thank you,
BV
Jun 7 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Ben Smeets | last post: by
1 post views Thread by Ed Brandmark | last post: by
4 posts views Thread by Max Harvey | last post: by
3 posts views Thread by ACaunter | last post: by
reply views Thread by CAIBird | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.