摘要:因为最近写界面的时候需要设置一个帮助的选项,所以希望点击帮助的时候可以弹出一个html的说明书,之前没有接触过,在网上搜了一下相关的资料,知道Retext 是Linux 下的MarkDown编辑器,可是实时的实现效果,因此花了一天的时间把它装上了,期间碰到了一些棘手的问题,在搜索了很多人的文章之后都一一得到了解决,所以想着把这些内容记录下来,可以供给需要的人进行参考:
参考的一些很有用的文章链接:
http://blog.csdn.net/ztsinghua/article/details/48382309
http://blog.csdn.net/ashimidashajia/article/details/48937553
http://blog.csdn.net/healthy_coder/article/details/50370316
https://segmentfault.com/q/1010000004444701
https://www.zhihu.com/question/20409634
以上的这些链接在这个过程中都对我提供了比较大的帮助
正文:
1)首先应该下载RetexT以及各类的安装包,具体下载安装包的方法以及链接详见第一个链接的文章,我就不再赘述
2)在安装Retext之前你首先需要安装Python3
安装Python的教程网上非常多,安装起来也很简单,只是需要安装的版本大于3.2,我安装的是3.4
注意:教程(第一个链接中)提到装Python以及Qt都是通过从epel仓库中通过yum安装,我没有尝试过(我都是下载安装包进行的安装),但是还是配置了epel仓库,cent中可以通过yum进行安装:<sudo yum -y install epel-release>,
3)安装Qt5
Qt的安装很简单,安装的过程都是界面话的操作,直接在Qt的官网下载相应的安装包,然后进行安装就可以了,只是安装过后需要添加qmake的环境变量,不然的话新的不能使用。
4)安装PyQt5
安装PyQt5是我花费时间最长的一步,因为在这其中出现了很多的问题
a、问题一
首先你需要对安装包里的文件configure.py进行编译,以生成Makefile文件,这里尤其需要注意的是之后需要加上qmake的参数,这里的qmake的路径一定要正确,不然的话就有可能出现错误
b、问题二
然后又出现错误了:Error: This version of PyQt5 and the commercial version of Qt have incompatiblelicenses.
与Qt的协议冲突了
修改configure.py,注释掉与协议冲突的代码:
# Common checks.
#if introspecting and target_config.qt_licensee != 'Open Source' and ltype == 'GPL':
# error(
# "This version of PyQt5 and the commercial version of Qt have "
# "incompatible licenses.")
重新对configure.py执行一次,这次就可以通过并且生成Makefile文件
c、问题三
接下来就要执行make、make install命令了,然而又出现错误
error: 'qgeolocation.h' file not found
#include <qgeolocation.h>
^
1 error generated.
make[1]: *** [sipQtPositioningcmodule.o] Error 1
make: *** [sub-QtPositioning-make_first-ordered] Error 2
解决办法:在/PyQt-gpl-5.5.1/QtPositioning
下创建一个
qgeolocation.h
文件,并将以下代码拷贝进去,保存,重新运行即可。
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtPositioning module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QGEOLOCATION_H
#define QGEOLOCATION_H
#include <QtCore/QSharedDataPointer>
#include <QtCore/QMetaType>
#include <QtPositioning/qpositioningglobal.h>
QT_BEGIN_NAMESPACE
class QGeoAddress;
class QGeoCoordinate;
class QGeoRectangle;
class QGeoLocationPrivate;
class Q_POSITIONING_EXPORT QGeoLocation
{
public:
QGeoLocation();
QGeoLocation(const QGeoLocation &other);
~QGeoLocation();
QGeoLocation &operator=(const QGeoLocation &other);
bool operator==(const QGeoLocation &other) const;
bool operator!=(const QGeoLocation &other) const {
return !(other == *this);
}
QGeoAddress address() const;
void setAddress(const QGeoAddress &address);
QGeoCoordinate coordinate() const;
void setCoordinate(const QGeoCoordinate &position);
QGeoRectangle boundingBox() const;
void setBoundingBox(const QGeoRectangle &box);
bool isEmpty() const;
private:
QSharedDataPointer<QGeoLocationPrivate> d;
};
Q_DECLARE_TYPEINFO(QGeoLocation, Q_MOVABLE_TYPE);
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QGeoLocation)
#endif
这样算是成功的将PyQt5安装好了!检测是否安装好:
python
>>> import PyQt5
>>> help(PyQt5)
5、安装retext
终于到了安装Retext这一步了,此时还需要利用Python-pip安装一些依赖包,又出现问题了
我找不到自己的python-pip装在了哪里,后来知道python 3.4之后是都自带的pip
所以直接使用命令python -m pip 就可以安装
需要安装的有 python -m pip markups
python -m pip markdown
python -m pip docutils
python -m pip pyenchant
安装完这些依赖项之后就可以安装retext啦
cd ReText-x.x.x
sudo python setup.py install
安装完成后在终端输入retext之后。你就可以开始使用retext啦
文章最开始给出的连接中最后一个连接就是教你怎么使用RETEXT的,很实用哦
【业余记录,有不足的地方还希望批评指正】