本文主要是介绍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 install gcc-c++
在安装QT 之前,还有可能要执行如下的命令,安装需要的依赖包
yum install libX*
安装python2.7
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.3To reconfigure, run 'gmake confclean' and 'configure'.
编译及安装
make ----意想不到的竟然花了7个小时
make install -----十分钟左右
安装pyqt4
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[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下说是时间不同步,调整下虚拟机时间
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 setSelectionRangei,j = self.toGuiIndex(i),self.toGuiIndex(j)File "/root/python_file/download/Leo-4.11-final/leo/plugins/qtGui.py", line 635, in toPythonIndexs = self.getAllText()File "/root/python_file/download/Leo-4.11-final/leo/plugins/qtGui.py", line 897, in getAllTextreturn g.u(s)File "/root/python_file/download/Leo-4.11-final/leo/core/leoGlobals.py", line 4659, in ureturn unicode(s)
TypeError: 'sip.methoddescriptor' object is not callable
找了半天不知道什么原因,也没找到这方面的资料
The install script will instruct you to add /usr/local/bin to your path. You can, instead, add the following link:
That’s it! See Running Leo for how to run Leo after installing it.
############哪里来的install文件呀,根本没有吗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放到该目录下安装运行,还是一样
/root/python_file/download/Leo-4.11-final
[root@centosTest Leo-4.11-final]# python launchLeo.py
[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之间的兼容性问题,导致安装期间出现了各种数不清的问题,最后最后关头,差点放弃,骂骂咧咧道,去他粮的,什么文学化编程呀,太难整了!但是还是多试了一遍并且安装成功了,想到成功之前的一刻,太难受了,差点放弃,想到马云的一句话(唉,阿里巴巴刚上市),今天很残酷,明天更残酷,后天很美好,很多人都死在明天晚上,看不到后天的太阳!!觉得特别有道理!无数次的尝试,无数次的失败,可以想见,成功是如何的来时不易,成功不是一蹴而就,在将要成功之时放弃,你可以找很多借口,你会觉得没办法,你会说你已经尽全力了!!!但是你放弃了,前面无数次的努力都是白费的,任何时候都要记得,成功是经过无数次白费的努力坚持下来的!!当你在困难面前放弃了,下次遇到问题,还是一样的结果,最后只会是一事无成!!!当你觉得你坚持不下去了,调整好心态,调整好心情,整理一下失败的经验,重新总结下问题的重点,然后重新面对难题,就当是你第一次碰到她,而在此时,你已经积累了很多宝贵的经验,你已经在一个更高的高度,所以决定最后成败的,不是技术,而是你重新面对问题的勇气!!!还有,在困难面前,你会学到的更多!!(近两点,晚安)
-----待续!!!!!!!!!
这篇关于leo 的安装的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!