How to install spynner in Linux environment

Original URL: http://www.yihaomen.com/article/linux/313.htm

 

Download spynner, the latest version: https://pypi.python.org/pypi/spynner/2.5

To develop desktop applications under linux, the most common development tool is QT, and python is the light cavalry of the open source world. It is easy to learn and efficient to develop. Therefore, with the pyqt package, python is used for QT development. The steps are described in detail below.
1. Basic environment configuration
2. Compile under centos, install QT-4.8.3
3. Install pyqt
4. Test the

basic environment
It is necessary to install g++.
yum -y install gcc automake autoconf libtool make
yum install gcc-c++

during installation Before QT, it is also possible to execute the following commands to install the required dependency packages
yum install libX*

1. Install python2.7 (refer to   this article http://www.yihaomen.com/article/linux/284.htm )
2. Change the python soft connection, because the python that comes with centos is 2.6.6, which does not meet the needs.

code  code

cd /usr/bin
rm -rf python
ln -s /usr/local/bin/python2.7 python
After doing this, it may cause a problem that the yum command cannot be used, then you need to modify yum
vi /usr/bin/yum
modification The python path in the first line #!/usr/bin/python2.6 because centos uses python2.6



Install PYQT SIP
Download pyqt sip:  http://nchc.dl.sourceforge.net/project/pyqt/sip/sip-4.14.1/sip-4.14.1.tar.gz
Run after decompression:
python configure.py
make
make install

PYQT
Install PYQT: http://nchc.dl.sourceforge.net/project/pyqt/PyQt4/PyQt-4.9.5/PyQt-x11-gpl-4.9.5.tar.gz
Download and unzip it.

code  code

[root@localhost PyQt-x11-gpl-4.9.5]# python configure.py 
[root@localhost PyQt-x11-gpl-4.9.5]# python configure.py 
Error: Make sure you have a working Qt qmake on your PATH or use the -q
argument to explicitly specify a working Qt qmake.


You find that the error is reported, it cannot be installed, and it is prompted that there is no qmake, 
because QT is not installed, so you have to install QT,
download address:  http://origin.releases.qt-project.org/qt4/source/qt-everywh ere -opensource-src-4.8.3.tar.gz
after decompression:

code  code

./configure (takes about 10 minutes)
results in:
Qt is now configured for building. Just run 'gmake'.
Once everything is built, you must run 'gmake install'.
Qt will be installed into /usr/local/Trolltech/ Qt-4.8.3

make (to wait a long time)
make install (to wait about 10 minutes)

The error may be that one of the following 3 is not installed, just install it:

sudo apt-get install libX11-dev libXext-dev libXtst-dev
You will find that QT4.8.3 is installed successfully, you can run the designer in the installation directory /usr/local/Trolltech/Qt-4.8.3/bin/

and then Reinstall PYqT

code  code

[root@localhost PyQt-x11-gpl-4.9.5]# python configure.py -q /usr/local/Trolltech/Qt-4.8.3/bin/qmake
Determining the layout of your Qt installation...
This is the GPL version of PyQt 4.9.5 (licensed under the GNU General Public
License) for Python 2.7.3 on linux2.

Type '2' to view the GPL v2 license.
Type '3' to view the GPL v3 license.
Type 'yes' to accept the terms of the license.
Type 'no' to decline the terms of the license.

Do you accept the terms of the license? yes


在configure 的时候,指定了qmake的路径.
成功之后,然后再 
make (要等一段时间)
make install
成功运行命令后,PYQT 安装成功.你可以在python解析器下,运行import PyQt4 来检测是否安装成功.

测试脚本,并运行

code 程序代码

import sys
from PyQt4 import QtGui
app = QtGui.QApplication(sys.argv)
widget = QtGui.QWidget()
widget.resize(250, 150)
widget.setWindowTitle('yihaomen.com QT TEST')
widget.show()
sys.exit(app.exec_())




所以在centos 下安装qt,pyqt的关键就是,安装的顺序,另外 pyqt sip 也很重要,一定要在安装pyqt前安装,因为这个东西决定安装在那个python下面吧,如果有多个python在机器上。另外就是定qmake  的路径。

 

然后安装spynner,解压缩进入spynner目录执行,python setup.py install

 

 

 

 

Running Spynner without X11

原文地址:http://blog.csdn.net/tengh/article/details/8268177

Xvfb is a virtual frame buffer X11 server that can be installed on linux servers without a monitor and graphics card. It can be customized for multiple displays and screens as well. In this tutorial i will show how to install, setup and configure a display. I am installing the Xvfb (X11 server) on a Centos/ Redhat linux system.

 

Example:

If you want to capture a screen shot but you have only a linux server running and no graphics card or monitor. To get the output you have to dump the virtual display to a file and then convert to suitable jpg or png graphics with ImageMagick

To Install Xvfb

yum install Xvfb

To intialize the display

Xvfb :1 -screen 0 800x600x24&

This sets the display number 1 and screen 0 to 800×600 resolution with the color depth of 24.

If you get error like

Fatal server error:
Couldn't add screen 0

then most probably you have set the color depth to 32bit which never worked for me. You have to set to 16 bit or 24 bit color for the virtual buffer.

To export the display to X11

export DISPLAY=localhost:1.0

If you get errors like while running Xvfb then you install necessary fonts

Could not init font path element unix/:7100, removing from list!
FreeFontPath: FPE "built-ins" refcount is 2, should be 1; fixing.

yum install xorg-x11-fonts*

It should in most cases fix the problem!

To Run a program in the virtual display.

 

 

Use Xvfb. It gives you an X server to doesn't connect to a physical display.

So, on CentOS, you'd do something like yum install xorg-x11-server-Xvfb.

You can then start it up on display :1 with the command /usr/X11R6/bin/Xvfb :1 -screen 0 1024x768x24 &. This will create a screen 1027x768 depth 24 and put the command into the background.

So, the environmental variable you'd specify before launching Firefox would be export DISPLAY=:1, pointing to whatever host is appropriate.

 

DISPLAY=localhost:1.0 firefox

 Xvfb :1 &

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326270834&siteId=291194637