leo 的安装

下载leo

-rw-r--r--.  1 root root   7282503 Sep 17  2014 Leo-4.11-final.zip

解压

[root@centosTest download]# unzip Leo-4.11-final.zip 

进入Leo然后看安装需求

[root@centosTest Leo-4.11-final]# more INSTALL.TXT 

@language rest
System requirements
-------------------


Leo requires the `Python`_ and `PyQt_` package.
The `PyEnchant`_ package is optional.

可以看到首先需要安装python和pyqt

如果你对这个有了解的话你会知道需要安装pyqt,你得首先安装好qt及sip

下载安装Pyqt4及sip:

http://www.riverbankcomputing.co.uk/software/pyqt/download


安装QT,
下载地址: http://origin.releases.qt-project.org/qt4/source/qt-everywhere-

如果没有安装qt就安装pyqt的话,会报如下类似错误:

[root@cognoswithdb2 PyQt-x11-gpl-4.11.2]#python configure.py

Error: Make sure you have a working Qtqmake on your PATH or use the -q

argument to explicitly specify a working Qtqmake.

有时候安装了qt还是会好上述错误的话,你可以制定qmake路径,如下

[root@cognoswithdb2 PyQt-x11-gpl-4.11.2]# python configure.py -q /usr/bin/qmake-qt4
Determining the layout of your Qt installation...
Error: Qt has been built as static libraries so either the -g or -k argument
should be used.
[root@cognoswithdb2 PyQt-x11-gpl-4.11.2]# python configure.py -q /usr/bin/qmake-qt4 -g
Determining the layout of your Qt installation...
This is the GPL version of PyQt 4.11.2 (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
Found the license file pyqt-gpl.sip.

基础环境搭建

yum -y install gcc automake autoconf libtool make
yum install gcc-c++
在安装QT 之前,还有可能要执行如下的命令,安装需要的依赖包
yum install libX*

安装python2.7

见我的博客 http://blog.csdn.net/fuwencaho/article/details/39452129

--20140923号修订:
安装好之后记得编辑下默认python,否则可能之后会有意想不到的错误,python2.6报错很奇怪
cd /usr/bin
rm -rf python
ln -s /usr/local/bin/python2.7 python
这样做了之后,可能导致一个问题yum 命令不能用,这时需要修改yum
vi /usr/bin/yum
修改第一行的python路径 #!/usr/bin/python2.6因为centos 是用的python2.6


好吧,言归正传,安装sip

下载;

-rw-r--r--.  1 root root    745329 Sep 18  2014 sip-4.14.1.tar.gz

解压;

[root@centosTest sip-4.14.1]# tar -zxvf sip-4.14.1.tar.gz 

[root@centosTest sip-4.14.1]# cd sip-4.14.1

编译:

[root@centosTest sip-4.14.1]# make
make[1]: Entering directory `/root/python_file/download/sip-4.14.1/sipgen'
gcc -c -pipe -O2 -w -DNDEBUG -I. -o main.o main.c
gcc -c -pipe -O2 -w -DNDEBUG -I. -o transform.o transform.c
gcc -c -pipe -O2 -w -DNDEBUG -I. -o gencode.o gencode.c
gcc -c -pipe -O2 -w -DNDEBUG -I. -o extracts.o extracts.c
gcc -c -pipe -O2 -w -DNDEBUG -I. -o export.o export.c
gcc -c -pipe -O2 -w -DNDEBUG -I. -o heap.o heap.c
gcc -c -pipe -O2 -w -DNDEBUG -I. -o parser.o parser.c
gcc -c -pipe -O2 -w -DNDEBUG -I. -o lexer.o lexer.c
g++  -o sip main.o transform.o gencode.o extracts.o export.o heap.o parser.o lexer.o 
make[1]: Leaving directory `/root/python_file/download/sip-4.14.1/sipgen'
make[1]: Entering directory `/root/python_file/download/sip-4.14.1/siplib'
gcc -c -pipe -fPIC -O2 -w -DNDEBUG -I. -I/usr/local/include/python2.7 -o siplib.o siplib.c
gcc -c -pipe -fPIC -O2 -w -DNDEBUG -I. -I/usr/local/include/python2.7 -o apiversions.o apiversions.c
gcc -c -pipe -fPIC -O2 -w -DNDEBUG -I. -I/usr/local/include/python2.7 -o descriptors.o descriptors.c
gcc -c -pipe -fPIC -O2 -w -DNDEBUG -I. -I/usr/local/include/python2.7 -o qtlib.o qtlib.c
gcc -c -pipe -fPIC -O2 -w -DNDEBUG -I. -I/usr/local/include/python2.7 -o threads.o threads.c
gcc -c -pipe -fPIC -O2 -w -DNDEBUG -I. -I/usr/local/include/python2.7 -o objmap.o objmap.c
gcc -c -pipe -fPIC -O2 -w -DNDEBUG -I. -I/usr/local/include/python2.7 -o voidptr.o voidptr.c
g++ -c -pipe -fPIC -O2 -w -DNDEBUG -I. -I/usr/local/include/python2.7 -o bool.o bool.cpp
g++ -shared -Wl,--version-script=sip.exp -o sip.so siplib.o apiversions.o descriptors.o qtlib.o threads.o objmap.o voidptr.o bool.o 
make[1]: Leaving directory `/root/python_file/download/sip-4.14.1/siplib'
[root@centosTest sip-4.14.1]# 

安装:

[root@centosTest sip-4.14.1]# make install
make[1]: Entering directory `/root/python_file/download/sip-4.14.1/sipgen'
cp -f sip /usr/local/bin/sip
make[1]: Leaving directory `/root/python_file/download/sip-4.14.1/sipgen'
make[1]: Entering directory `/root/python_file/download/sip-4.14.1/siplib'
cp -f sip.so /usr/local/lib/python2.7/site-packages/sip.so
strip /usr/local/lib/python2.7/site-packages/sip.so
cp -f /root/python_file/download/sip-4.14.1/siplib/sip.h /usr/local/include/python2.7/sip.h
make[1]: Leaving directory `/root/python_file/download/sip-4.14.1/siplib'
cp -f sipconfig.py /usr/local/lib/python2.7/site-packages/sipconfig.py
cp -f /root/python_file/download/sip-4.14.1/sipdistutils.py /usr/local/lib/python2.7/site-packages/sipdistutils.py
[root@centosTest sip-4.14.1]# 



----安装sip期间遇到问题

make的时候,报错如下

siplib.c: In function ‘register_exit_notifier’:
siplib.c:12054: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘md’
siplib.c:12054: error: ‘md’ undeclared (first use in this function)
siplib.c:12054: error: expected expression before ‘{’ token
siplib.c:12058: error: ‘PyObject’ undeclared (first use in this function)
siplib.c:12058: error: ‘notifier’ undeclared (first use in this function)
siplib.c:12058: error: ‘atexit_module’ undeclared (first use in this function)
siplib.c:12058: error: ‘register_func’ undeclared (first use in this function)
siplib.c:12058: error: ‘res’ undeclared (first use in this function)
siplib.c: At top level:
siplib.c:12088: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘get_from_convertor’
siplib.c: In function ‘sip_api_enable_autoconversion’:
siplib.c:12126: error: ‘sipPyObject’ has no member named ‘next’
siplib.c:12132: error: ‘PyObject’ undeclared (first use in this function)
siplib.c:12132: error: expected expression before ‘)’ token
siplib.c:12132: error: ‘const union <anonymous>’ has no member named ‘td_py_type’
siplib.c:12132: error: too many arguments to function ‘addPyObjectToList’
siplib.c: In function ‘autoconversion_disabled’:
siplib.c:12146: error: ‘PyObject’ undeclared (first use in this function)
siplib.c:12146: error: ‘type’ undeclared (first use in this function)
siplib.c:12146: error: expected expression before ‘)’ token
siplib.c:12146: error: ‘const union <anonymous>’ has no member named ‘td_py_type’
siplib.c:12149: error: ‘sipPyObject’ has no member named ‘next’
siplib.c:12150: error: ‘sipPyObject’ has no member named ‘object’
siplib.c: At top level:
siplib.c:12160: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
siplib.c:12199: error: expected ‘)’ before ‘*’ token
siplib.c: In function ‘deref_mixin’:
siplib.c:12219: error: ‘sipSimpleWrapper’ has no member named ‘mixin_main’
siplib.c:12219: error: ‘sipSimpleWrapper’ has no member named ‘mixin_main’
siplib.c: At top level:
siplib.c:12226: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
make[1]: *** [siplib.o] Error 1
make: *** [all] Error 2

就这样一直往后上都看不到头了,总是找不到原因,

Google找make[1]: *** [siplib.o] Error 1

make: *** [all] Error 2半天也没找到解决方法,什么ldconfig呀等等都不行,看来没找对方法用什么浏览器都没用呀!唉,没办法,把错误重定向到文件然后再看

[root@cognoswithdb2 downpython]# more haha.err 
siplib.c:20:20: error: Python.h: No such file or directory
In file included from siplib.c:28:
sip.h:50:2: error: #error "This version of SIP requires Python v2.3 or later"
In file included from siplib.c:28:
sip.h:357: error: expected declaration specifiers or ‘...’ before ‘PyObject’
sip.h:358: error: expected declaration specifiers or ‘...’ before ‘PyObject’
sip.h:358: error: expected declaration specifiers or ‘...’ before ‘PyObject’
sip.h:358: error: expected declaration specifiers or ‘...’ before ‘PyObject’
sip.h:358: error: expected declaration specifiers or ‘...’ before ‘PyObject’
sip.h:359: error: expected ‘)’ before ‘*’ token
sip.h:361: error: expected declaration specifiers or ‘...’ before ‘visitproc’
sip.h:367: error: expected ‘)’ before ‘*’ token
sip.h:368: error: expected ‘)’ before ‘*’ token
sip.h:373: error: expected ‘)’ before ‘*’ token
sip.h:374: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
sip.h:378: error: expected declaration specifiers or ‘...’ before ‘PyObject’


呵呵。应该定位到问题了
网上找到解决方法试下http://blog.csdn.net/tianxiajianling/article/details/6636204
[root@cognoswithdb2 sip-4.16.3]# yum install python-devel
果然安装成功了

安装qt:

下载

-rw-r--r--.  1 root     root  233635127 Sep 18  2014 qt-everywhere-opensource-src-4.8.3.tar.gz

解压安装

./configura   (约十分钟)

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


To reconfigure, run 'gmake confclean' and 'configure'.

编译及安装

make  ----意想不到的竟然花了7个小时

make install   -----十分钟左右


安装pyqt4

-rw-r--r--.  1 root     root   11120742 Sep 17 23:47 PyQt-x11-gpl-4.11.2.tar.gz
解压编译,编译的时候说我的sip版本太低,下在最新版重新安装
-rw-r--r--.  1 root     root     794305 Sep 18 01:04 sip-4.16.3.tar.gz
安装完成之后安装pyqt4
编译的时候报错
python configure.py
Creating pylupdate4 Makefile...
Creating pyrcc4 Makefile...
The Qt Designer plugin was disabled because a dynamic Python library couldn't
be found
Creating pyqtconfig.py...
[root@centosTest PyQt-x11-gpl-4.11.2]# 

不是很明白,好像是缺少python库,安装试试看

[root@cognoswithdb2 sip-4.16.3]# yuminstall python-devel



然后make,但是又出错了
报错如下
make[2]: Entering directory `/root/python_file/download/PyQt-x11-gpl-4.11.2/qpy/QtDeclarative'
/usr/local/Trolltech/Qt-4.8.3/bin/qmake -o Makefile w_qpydeclarative.pro
make[2]: Leaving directory `/root/python_file/download/PyQt-x11-gpl-4.11.2/qpy/QtDeclarative'
make[2]: Entering directory `/root/python_file/download/PyQt-x11-gpl-4.11.2/qpy/QtDeclarative'
/usr/local/Trolltech/Qt-4.8.3/bin/qmake -o Makefile w_qpydeclarative.pro
make[2]: Leaving directory `/root/python_file/download/PyQt-x11-gpl-4.11.2/qpy/QtDeclarative'
make[2]: Entering directory `/root/python_file/download/PyQt-x11-gpl-4.11.2/qpy/QtDeclarative'
/usr/local/Trolltech/Qt-4.8.3/bin/qmake -o Makefile w_qpydeclarative.pro
make[2]: Leaving directory `/root/python_file/download/PyQt-x11-gpl-4.11.2/qpy/QtDeclarative'
make[2]: Entering directory `/root/python_file/download/PyQt-x11-gpl-4.11.2/qpy/QtDeclarative'
/usr/local/Trolltech/Qt-4.8.3/bin/qmake -o Makefile w_qpydeclarative.pro
Warning: File `qpydeclarative.pro' has modification time 1.8e+06 s in the future

而且是一直循环报这个错,google下说是时间不同步,调整下虚拟机时间
[root@centosTest PyQt-x11-gpl-4.11.2]# date -s "2014-09-22 19:47"

重新make成功(小插曲:make的时候说 ImportError: No module named sipconfig ,重新安装下sip解决)
然后
make install | tee makeinstall.log
成功

测试pyqt安装完成
测试脚本testgui.py
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_())

python testgui,py 会生成一个窗口,则成功


现在安装leo

[root@centosTest Leo-4.11-final]# python launchLeo.py 
launchLeo.py: cannot connect to X server 
[root@centosTest Leo-4.11-final]# 
我是在securet CRT中运行,无法启动x windows。到虚拟机中去启动
发现闪退现象,然后报错如下
  File "/root/python_file/download/Leo-4.11-final/leo/plugins/qtGui.py", line 705, in setSelectionRange
    i,j = self.toGuiIndex(i),self.toGuiIndex(j)
  File "/root/python_file/download/Leo-4.11-final/leo/plugins/qtGui.py", line 635, in toPythonIndex
    s = self.getAllText()
  File "/root/python_file/download/Leo-4.11-final/leo/plugins/qtGui.py", line 897, in getAllText
    return g.u(s)
  File "/root/python_file/download/Leo-4.11-final/leo/core/leoGlobals.py", line 4659, in u
    return unicode(s)
TypeError: 'sip.methoddescriptor' object is not callable

找了半天不知道什么原因,也没找到这方面的资料
看官方文档:
install:http://leoeditor.com/installing.html#installing-from-sources-linux
run:http://leoeditor.com/running.html
也没发现哪里做错了,为了确保万一,还安装了 PyEnchant,但是还是不行,都快要疯了,为了安装这个,将近花了一周的空余时间,竟然还是装不起,没办法,最好随便试试了
仔细看官方文档,发现可以在解释器下也可以执行
python
>>>
import leo
leo.run() # runs Leo, opening a new outline or,
leo.run(fileName=aFileName) # runs Leo, opening the given file name.

发现不闪退了,界面是出来了,但是确实功能不全的界面,啥选项都没有!!!怎么办??为什么,,究竟是咋了???都快要放弃了

然后看到还有install,为什么我看到有些解压后直接运行python launchLeo.py,不管了,死马当活马医
#############官网如下
  1. cd ~/leo-4-11-final # Change version as appropriate.
    chmod u+x install
    sudo ./install

The install script will instruct you to add /usr/local/bin to your path. You can, instead, add the following link:

sudo ln -s /usr/local/lib/leo/ /usr/local/lib/python2.6/site-packages/

That’s it! See Running Leo for how to run Leo after installing it.

############哪里来的install文件呀,根本没有吗
倒是看到了
-rw-r--r--.  1 root root   6165 Nov  6  2013 setup.py
python setup.py --help
看到安装命令是这样
python setup.py install
安装之后运行python launchLeo.py
还是跟没安装之前一样,包括在解释器中执行!

怎么办,在进unzip后的源码
more INSTALL.TXT
看到这样一句话
If the sources are zipped, unpack them
into a temp folder. You may place the sources anywhere you like, including
Python's *site-packages* folder, for example,
C:\Python26\Lib\site-packages.

 find / -name site-packages -type d
找到2.7的,把leo放到该目录下安装运行,还是一样

仔细看之前的pyqt的编译安装,发现他好像使用的是python2.6.而不是2.7.记得当时我安装2.7环境的时候不是把2.6的给覆盖掉了吗(见python安装部分,怎么还是没覆盖以前的样子)
没办法,重新覆盖一遍:
cp /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/bin/python2.7 python

好,重新执行
[root@centosTest Leo-4.11-final]# pwd
/root/python_file/download/Leo-4.11-final
[root@centosTest Leo-4.11-final]# python launchLeo.py 


报什么_sqlite3 模块未找到

很奇怪的错误,为什么之前2.6环境的时候没有报这个错,find 一下这个文件,发现之后2.6路径下有一个_sqlite2.so文件有点像

[root@centosTest Leo-4.11-final]# python launchLeo.py ^C
[root@centosTest Leo-4.11-final]# find / -name _sqlite3* -type f
/root/python_file/download/Python-2.7.3/PC/VC6/_sqlite3.dsp
/root/python_file/download/Python-2.7.3/PC/VS8.0/_sqlite3.vcproj
/root/python_file/download/Python-2.7.3/PC/VS7.1/_sqlite3.vcproj
/root/python_file/download/Python-2.7.3/PCbuild/_sqlite3.vcproj
/usr/lib64/python2.6/lib-dynload/_sqlite3.so

好吧,就把你cp到2.7环境下看看吧

cp /usr/lib64/python2.6/lib-dynload/_sqlite3.so /usr/local/lib/python2.7/sqlite3/_sqlite3.so  (目标路径根据报错得出)

重新 python launchLeo.py 

发现报另外的错了,没有pyqt4 模块,这难道还要重新安装一遍pyqt,没办法,反正是死马

重新编译安装sip ,pyqt4(这是python configure.py 的时候,因为python调用的是2.7环境,所以她们也是安装在2.7环境下,我是这样理解的)

好吧,一个小时之后,奇迹发生了




--总结,安装leo,花了将近一周的闲暇时间,平均每天晚上整到近两点(都不好意思说),因为对python的不熟悉,因为QT,PYQT,SIP,python之间的兼容性问题,导致安装期间出现了各种数不清的问题,最后最后关头,差点放弃,骂骂咧咧道,去他粮的,什么文学化编程呀,太难整了!但是还是多试了一遍并且安装成功了,想到成功之前的一刻,太难受了,差点放弃,想到马云的一句话(唉,阿里巴巴刚上市),今天很残酷,明天更残酷,后天很美好,很多人都死在明天晚上,看不到后天的太阳!!觉得特别有道理!无数次的尝试,无数次的失败,可以想见,成功是如何的来时不易,成功不是一蹴而就,在将要成功之时放弃,你可以找很多借口,你会觉得没办法,你会说你已经尽全力了!!!但是你放弃了,前面无数次的努力都是白费的,任何时候都要记得,成功是经过无数次白费的努力坚持下来的!!当你在困难面前放弃了,下次遇到问题,还是一样的结果,最后只会是一事无成!!!当你觉得你坚持不下去了,调整好心态,调整好心情,整理一下失败的经验,重新总结下问题的重点,然后重新面对难题,就当是你第一次碰到她,而在此时,你已经积累了很多宝贵的经验,你已经在一个更高的高度,所以决定最后成败的,不是技术,而是你重新面对问题的勇气!!!还有,在困难面前,你会学到的更多!!(近两点,晚安)

-----待续!!!!!!!!!


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值