By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,050 Members | 1,020 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,050 IT Pros & Developers. It's quick & easy.

just want to open a simple window keep getting this error

P: 2
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
Share this Question
Share on Google+
3 Replies


bvdet
Expert Mod 2.5K+
P: 2,851
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

P: 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
Expert Mod 2.5K+
P: 2,851
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.