Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

发表在 未分类 | 1条评论

Flash CS5绿色版 Java运行时环境初始化时出现错误

  Flash CS5绿色版 java运行时环境初始化时出现错误  

  现象:每次运行都报java运行时环境初始化时出现错误,请重装的错误。  

  1.对做动画设计的人没什么影响.  

  2.影响AS3的程序设计人员,在帧上调入代码编辑时不能使用.  

  3.所有编辑后的swf文件中as3代码都不能用.  

  问题原因:  

  1. 由于adobe cs 5将java运行时放到windows公共目录下面了。  

  2. 精简绿化后的Flash CS5并没有带JVM目录,且没有将运行环境COPY至相应位置。  

  解决办法:  

  1.人工添加java运行库到windows公共目录。  

  1.1 将java运行时jre目录拷贝到  

  XP的目录为C:Documents and SettingsAll UsersApplication DataAdobe,在C:Documents and SettingsAll UsersApplication DataAdobe目录下新建一个CS5目录,把jre文件夹复制到该目录下。  

  vista和windows 7的目录为C:ProgramDataAdobe,在C:ProgramDataAdobe目录下新建一个CS5目录,把jre文件夹复制到该目录下。  

  如果cs5目录不存在新建之。  

  1.2 JVM目录拷贝过来的记得将目录名改成jre。 

发表在 未分类 | 发表评论

macport install py26-sip出错解决办法

—>  Computing dependencies for py26-sip
—>  Configuring py26-sip
Error: Target org.macports.configure returned: configure failure: shell command failed
Log for py26-sip is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py26-sip/main.log
Error: Status 1 encountered during processing.
To report a bug, see <http://guide.macports.org/#project.tickets>
卡在这里 网上搜到是–disable-dependency-tracking这个参数的问题,但是研究怎么取消这个参数肥好大劲,加上以下参数就行了。。。:
configure.universal_args=''

例如: sudo port install py26-sip configure.universal_args=”

或者也许这样也行:sudo port install py26-sip configure.universal_args-delete –disable-dependency-tracking
发表在 未分类 | 发表评论

Fix “Ignoring File .save In Directory /etc/apt/sources.list.d/ As It Has An Invalid Filename Extension” In Ubuntu 10.10


I just did a clean Ubuntu 10.10 Maverick Meerkat install on my main computer. Not because I wanted but because my Lucid install was very unstable do to the lost of tests I do for WebUpd8 posts (don’t worry, if something I test goes bad, I don’t post it on WebUpd8 so everything we post is mostly stable). I tried to upgrade from Ubuntu 10.04 to Ubuntu 10.10 but it didn’t go too well. Actually it didn’t boot at all with some serious crashes while booting so I did a fresh install.

I didn’t encounter any major bugs in Ubuntu 10.10 so far, but there’s one small but very annoying bug so far: after you add a PPA and run "sudo apt-get update", an error is displayed:


N: Ignoring file ‘THE_PPA.list.save’ in directory ‘/etc/apt/sources.list.d/’ as it has an invalid filename extension

And the more PPAs you add, the more errors like this you’ll be getting. And you can’t install anything from those PPA until you remove all the .save files from /etc/apt/sources.list.d/ manually.
But I found a permanent fix in a comment on this bug so you don’t have to keep deleting files from /etc/apt/sources.list.d/. Simply run the following command in a terminal:

echo "Dir::Ignore-Files-Silently:: ".save$";" | sudo tee /etc/apt/apt.conf.d/99ignoresave

发表在 未分类 | 发表评论

apt-fast

Remember apt-fast? Allow me to remind you: apt-fast is a simple bash script that speeds up apt-get download speed (so you would run "sudo apt-fast install firefox" to install Firefox for example) by using Axel, a command line application which accelerates HTTP/FTP downloads by using multiple sources for one file. The author claims it’s roughly 26x faster than the normal apt-get and I don’t know if that’s true, but a lot of users are reporting visible download speed improvements
A while back, Apt-Fast got full Apt-Get syntax replacement and now you can finally install Apt-Fast from a PPA so it’s easier to install, even by non-technical users.

To install apt-fast in Ubuntu, simply copy/paste the following commands in a terminal:

sudo add-apt-repository ppa:tldm217/tahutek.net
sudo apt-get update
sudo apt-get install apt-fast

The above PPA is available for Ubuntu 9.10 Karmic Koala, 10.04 Lucid Lynx and 10.10 Maverick Meerkat!

发表在 未分类 | 发表评论

PyQt/Qt中使用image

    Qt中使用图片资源,用得最多的就是图标了。静态图标或者图片一般这样加载:
      1. 编写qt resource文件,格式大致如下      //——————–images.qrc———————-//
       !DOCTYPE RCC>RCC version="1.0">
       qresource
prefix="/">
            file>images/quit.png/file>
            file>images/login.png/file>
            file>images/open.png/file>
      /qresource>
      /RCC>
      2. 使用pyrcc4编译qt resource,生成py文件(如果是C++版本的话,使用rcc)
      pyrcc4 images.qrc -o images_rc.py
      3. 在程序中import images_rc,然后就可以使用了,  比如,为open菜单添加一个图标      self.actionOpen = QtGui.QAction(self)
self.actionOpen.setIcon( QtGui.QIcon(":/images/open.png") )
      这种方法的特点就是肯定不会出错,即使用py2exe打包后,而且兼容性很好。但是不足是程序会变大,因为图片资源都静态编译到二进制程序中去了。
      另外一种加载图片或者图标的方法是我在做QZone的爬虫时遇到的问题:登陆QZone需要验证码,验证码可以通过访问腾讯的固定网址刷新,通过python的urllib/urllib2可以很容易下载下来手动输入,但是需要做到GUI里面的话,因为图片随时可以刷新,就不能编译成静态的二进制了。查了一下Qt的文档,发现QPixmap这个类可以直接从硬盘上的文件加载,文档中是这样描述的:
      ———————————————————-      
     QPixmap::QPixmap ( const 
QString
fileName, const char * format = 0, 
Qt::ImageConversionFlags
flags = Qt::AutoColor )
      Constructs a pixmap from the file with the given fileName. If the file does not exist or is of an unknown format, the pixmap becomes a null pixmap.
      …
      The file name can either refer to an actual file on disk or to one of the application’s embedded resources. See the 
Resource System
overview for details on how to embed images and other resource files in the application’s executable. 
      ———————————————————-
      这个fileName既可以是qt resource的文件,也可以是一个物理文件,所以就解决了我的问题:我先将验证码下载下来,然后实例化一个QPixmap对象,生成一个QIcon,添加到一个Button上就可以了:
pixmap = QtGui.QPixmap( ‘verifcode.jpg’ )
icon =
QtGui.QIcon( pixmap )
self.verifCodeButton.setIcon( icon )
      不过后来发现QPixmap还有两个重载的函数loadFromData:    
      bool 
loadFromData
( const uchar * data, uint len, const char * format = 0, Qt::ImageConversionFlags flags = Qt::AutoColor )
      bool 
loadFromData
( const QByteArray & data, const char * format = 0, Qt::ImageConversionFlags flags= Qt::AutoColor )
      因为我从url请求得到的图片数据本来就是二进制的数据,先是通过write生成jpg文件,再用QPixmap加载的,能不能直接把从url请求得到的数据直接load进去呢?因为第一个函数需要知道字节长度,查了下QByteArray的定义,我选择第二个函数,结果一试就成功啦,代码如下:
pixmap = QtGui.QPixmap()
imgdata = self.reqVerifCode()   # req the image data of verify
code
bool = pixmap.loadFromData( QtCore.QByteArray(imgdata) )
if bool:
    icon
= QtGui.QIcon( pixmap )
    self.veriCodeButton.setIcon( icon )
else:
    QtGui.QMessageBox.warning( None, u’警告’, 
                    u"加载验证码失败" )
      正当我高兴之余,用py2exe打包后,发现我的button显示不出来图片,我开始以为程序有问题,但是直接用python.exe来执行明明就work得很好的。在确定代码没有问题后,我开始怀疑自己的setup.py有问题,我不确定是不是缺了某些库没加进去。于是Google之,关键词’py2exe Pixmap’,相关信息较少,不过这个问题貌似有人碰到过,昨晚试了好几种方法,都没有得到解决。今天终于在
这个地址
找到了解决办法:
      You may try creating folder "imageformats" in the folder with
your binary app and add DLLs from PyQt4 imageformats folder (
C:Python26Libsite-packagesPyQt4pluginsimageformats.
)
      就是把PyQt4pluginsimageformats文件夹复制到你py2exe打包后可执行文件的目录下,其实我后来发现,imageformats里有6个dll文件,分别是qgif4.dll,qico4.dll,qjpeg4.dll,qmng4.dll,qsvg4.dll和qtiff4.dll,我猜想都是些使用图片资源需要的动态链接库,只需要保留qjpeg4.dll就可以了,因为我的验证码使用的是jpg的格式。修改setup.py文件后重新打包,至此,该问题得以圆满解决。
发表在 未分类 | 发表评论

(Python科学计算包)NumPy文档:8.2矩阵对象

注:转载请注明出处http://www.kgblog.net 
注:NumPy是Numarray的后继者,用来代替NumArray。SAGE是基于NumPy和其他几个工具所整合成的数学软件包,目标是取代Magma, Maple, Mathematica和Matlab 这类工具。

今天我想在网上找一些关于NumPy的介绍,并试一下用NumPy求逆矩阵的时候,竟然找不到任何中文的资料,有网友在论坛请教“怎么用python进行矩阵求逆”,也无一人回答。因此我找到NumPy的官方文档,其中有一小节内容是介绍矩阵对象的,于是我就把这一节翻译成中文,作出点微小的贡献,时间较短,没怎么检查拼写错误,有问题请原谅。翻译者:Keengle(http://www.kgblog.net)。

8.2 矩阵(Matrix)对象

Matrix类型继承于ndarray类型,因此含有ndarray的所有数据属性和方法。Matrix类型与ndarray类型有六个重要的不同点,当你当Matrix对象当arrays操作时,这些不同点会导致非预期的结果。

1)Matrix对象可以使用一个Matlab风格的字符串来创建,也就是一个以空格分隔列,以分号分隔行的字符串。

2)Matrix对象总是二维的。这包含有深远的影响,比如m.ravel()的返回值是二维的,成员选择的返回值也是二维的,因此序列的行为与array会有本质的不同。

3)Matrix类型的乘法覆盖了array的乘法,使用的是矩阵的乘法运算。当你接收矩阵的返回值的时候,确保你已经理解这些函数的含义。特别地,事实上函数asanyarray(m)会返回一个matrix,如果m是一个matrix。

4)Matrix类型的幂运算也覆盖了之前的幂运算,使用矩阵的幂。根据这个事实,再提醒一下,如果使用一个矩阵的幂作为参数调用asanarray(…)跟上面的相同。

5)矩阵默认的__array_priority__是10.0,因而ndarray和matrix对象混合的运算总是返回矩阵。

6)矩阵有几个特有的属性使得计算更加容易,这些属性有:

(a) .T -- 返回自身的转置

(b) .H -- 返回自身的共轭转置

(c) .I -- 返回自身的逆矩阵

(d) .A -- 返回自身数据的2维数组的一个视图(没有做任何的拷贝)

 

Matrix类是ndarray的一个Python子类,你也可以学习这个实现来构造自己的ndarray子类。Matrix对象也可以使用其它的Matrix对象,字符串,或者其它的可以转换为一个ndarray的参数来构造。另外,在NumPy里,“mat”是“matrix”的一个别名。

例1: 使用字符串构造矩阵

>>> from numpy import *

>>> a=mat(’1 2 3; 4 5 3′)

>>> print (a*a.T).I

[[ 0.29239766 -0.13450292]

 [-0.13450292  0.08187135]]

 

例2: 使用嵌套序列构造矩阵

>>> mat( [ [1,5,10],[1.0,3,4j] ])

matrix([[  1.+0.j,   5.+0.j,  10.+0.j],

        [  1.+0.j,   3.+0.j,   0.+4.j]])

 

例3: 使用一个数组构造矩阵

>>> mat( random.rand(3,3) ).T

matrix([[ 0.81541602,  0.73987459,  0.03509142],

        [ 0.14767449,  0.60539483,  0.05641679],

        [ 0.43257759,  0.628695  ,  0.47413553]])

 

Matrix( data, dtype=None, copy=True )

将以参数data传进来的数据转换为矩阵。如果dtype是None,那么数据类型将由data的内容来决定。如果copy为True,则会拷贝data中的数据,否则会使用原来的数据缓冲。如果没有找到数据的缓冲区,当然也会进行数据的拷贝。注意:矩阵matrix事实上是一个类型,因此当你构造实例的时候会调用matrix.__new__(matrix, data, dtype, copy)。

Mat

只是matrix的一个别名。

Asmatrix(data, dtype=None)

返回不经过复制的数据。等价于matrix(data, dtype, copy=False)。

Bmat(obj, ldict=None, gdict=None)

使用一个字符串,嵌套的序列或者一个数组(array)构造一个矩阵。这个命令允许你从其它的对象来建立起矩阵。其中当obj是一个字符串的时候才会使用参数ldict和gdict,这两个参数是局部和模块的字典。如果你没有提供它们,这些将由系统提供。

>>> A=mat(’2 2; 2 2′); B=mat(’1 1; 1 1′);

>>> print bmat(‘A B; B A’)

[[2 2 1 1]

 [2 2 1 1]

 [1 1 2 2]

 [1 1 2 2]]

 

注:转载请注明出处http://www.kgblog.net 

发表在 未分类 | 发表评论