How to use gfx module in python

5.3k Views Asked by At

I'm trying to use the gfx module for python (from here: http://www.swftools.org/gfx_tutorial.html). But when I do python setup.py build I get an error:

ImportError: cannot import name CompileError

I just need to open a gfx file.. (Its part of the pythonchallenge.com) How can I do it?

I'm working on linux mint 64bit

2

There are 2 best solutions below

1
On BEST ANSWER

download

http://www.swftools.org/download.html

You can build the Python module using setup.py
You can build it "manually" by using make To do the former, all that should be required is

python setup.py build
python setup.py install

This is the preferred way. If the above gives you any trouble or you prefer make, the following will also create the Python module:

./configure
make
# substitute the following path with your correct python 
installation:
cp lib/python/*.so /usr/lib/python2.4/site-packages/

You can test whether the python module was properly installed by doing

python -c 'import gfx'
8
On

enter code here Not sure how stable this is but there seems to be a lot of issues installing 0.9.2 on ubuntu:

wget http://www.swftools.org/swftools-2013-04-09-1007.tar.gz
tar -xzvf swftools-2013-04-09-1007.tar.gz 
cd swftools-2013-04-09-1007/
./configure
make
sudo make install
sudo cp lib/python/*.so /usr/lib/python2.7/site-packages/

That should compile and install on ubuntu. Then python -c 'import gfx' should work.

I had a look at the setup.py script and it seems it is using CompileError from distutils which is now depreciated, I replaced it with from distutils.core import CCompilerError

Running python setup.py runs after changing but complains about various errors in relation to jpeg and PIL._imaging.so so I have included an instuctions.txt in the file which has instructions on how to setup the required packages and symlinks etc...

I also had to add the lib/art directory from swftools on github and add it to the lib directory.

It runs and installs on ubuntu 14.04 but should work on mint also.

The updated package is here