13

I have a pygame game and I want to use pygame.gfxdraw.aacricle(), but whenever I do it gives me an error:

AttributeError: 'module' object has no attribute 'gfxdraw'

How do I install gfx for python 2.7?

lemiant
  • 4,205
  • 4
  • 31
  • 38

2 Answers2

16

I had this same issue using gfxdraw in pygame as well. Once I imported the module explicitly, there were no issues. Adding this line after importing pygame fixed the issue:

import pygame.gfxdraw

Curiously, I don't need to import pygame.draw explicitly in order to use it.

GrantJ
  • 8,162
  • 3
  • 52
  • 46
  • 1
    Awesome, this is exactly what I had to do to fix the application I was developing (Python 2.7, latest pygame, Ubuntu x64). – Breakthrough Jan 03 '13 at 05:06
0

Here is the compilation and installation guide for gfx.

For the basic install it's the standard:

python setup.py build
python setup.py install

Or did you already try this and run into some problems?

Levon
  • 138,105
  • 33
  • 200
  • 191
  • 1
    I went to that website and downloaded the file they suggested: http://www.swftools.org/download.html . It was an exe, so I ran it and gfx still isn't installed. I have no idea what the instruction means. – lemiant May 25 '12 at 18:39
  • @lemiant did you get any sort of error/warning messages during the installation? – Levon May 25 '12 at 18:40
  • No it went through clean. It just didn't have any obvious effects. – lemiant May 25 '12 at 18:49
  • In fact the download linked there isn't even a compressed file – lemiant May 25 '12 at 19:00
  • @lemiant it's not that unusual for install packages to be in .exe format. I am assuming you've tried to reinstall this? Is it possible you've run into some permission problems (though I would expect some error/warning messages in that case) i.e., did you have to install this as administrator? Is there a pygame forum you could post your query? Did you download this version? http://wiki.swftools.org/wiki/Installation#How_do_I_install_swftools_on_Windows.3F – Levon May 25 '12 at 19:11
  • I don't believe this is `pygame.gfxdraw` , but `gfx`. I just tested my pygame, and `import pygame.gfxdraw` worked. I don't believe I did a second install, just pygame-1.9.2-pre. – ninMonkey May 25 '12 at 22:45
  • Monkey, you got it, thanks! I would have expected "import pygame" to import everything, but apparently it doesn't. You should make that an answer – lemiant May 28 '12 at 15:34