简体   繁体   English

如何在python中使用gfx模块

[英]How to use gfx module in python

I'm trying to use the gfx module for python (from here: http://www.swftools.org/gfx_tutorial.html ). 我正在尝试将gfx模块用于python(从此处: http ://www.swftools.org/gfx_tutorial.html)。 But when I do python setup.py build I get an error: 但是当我执行python setup.py build ,出现错误:

ImportError: cannot import name CompileError ImportError:无法导入名称CompileError

I just need to open a gfx file.. (Its part of the pythonchallenge.com) How can I do it? 我只需要打开一个gfx文件即可。(它是pythonchallenge.com的一部分)我该怎么办?

I'm working on linux mint 64bit 我正在Linux Mint 64位上工作

enter code here Not sure how stable this is but there seems to be a lot of issues installing 0.9.2 on ubuntu: enter code here不确定它的稳定性如何,但在ubuntu上安装0.9.2似乎有很多问题:

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. 那应该编译并安装在ubuntu上。 Then python -c 'import gfx' should work. 然后python -c 'import gfx'应该工作。

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 我有一个看看setup.py脚本,它似乎它使用CompileErrordistutils也就是现在贬值了,我取代它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... 运行python setup.py会在更改后运行,但会抱怨与jpegPIL._imaging.so相关的各种错误,因此我在文件中包含了instuctions.txt ,其中包含有关如何设置所需软件包和符号链接等的说明。

I also had to add the lib/art directory from swftools on github and add it to the lib directory. 我还必须从github上的swftools添加lib / art目录,并将其添加到lib目录。

It runs and installs on ubuntu 14.04 but should work on mint also. 它可以在ubuntu 14.04上运行并安装,但也可以在mint上运行。

The updated package is here 更新的软件包在这里

download 下载

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

You can build the Python module using setup.py 您可以使用setup.py构建Python模块
You can build it "manually" by using make To do the former, all that should be required is 您可以使用make来“手动”构建它。要做到前者,所需要做的就是

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: 如果以上给您带来麻烦或您更喜欢make,则以下内容也会创建Python模块:

./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模块是否已正确安装

python -c 'import gfx'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM