设为首页 收藏本站
查看: 2640|回复: 0

[经验分享] Mac OS X 10.11.1下搭建Python3.4 + PyQt5.5.1 +Eric6.1.1开发平台

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-1-15 08:56:12 | 显示全部楼层 |阅读模式
由于Python易学、开源、面向对象、可移植性高、库丰富的特点,近期开始学习Python。百度了解了各款Python IDE后,还是认为Eric比较适合我,所以踏上了安装Eric坎坷之路,从选定工具到安装成功一共花费了8天时间,从Windows到Linux再到Mac,挨个折腾了一遍,Windows的搭建比较简单,下载好相应版本直接运行exe就行了,Linux和Mac下我都是用源码包安装的,所以遇到了不少问题最后,终于在Mac上研究明白了。把搭建的整个过程写下来,和与我一样的小白分享。

PS:Mac与Linux的搭建没什么区别,Linux下的也可参考本文,由于我安装过xcode所以gcc我没有再单独去安装,没有的请根据提示自行安装。
一、准备文件

    Python3.4

    Qt5.5.1

    SIP4.17

    QScintilla2.9.1

    PyQt5.5.1

二、安装过程
1.安装Python3.4

            从官网(https://www.python.org/download)下载相应平台的版本安装即可

        注意!!

    如果您是iOS开发者,请不要删除python2.7,因为Xcode使用的2.7的脚本,不支持3以上版本!!!

2.安装Qt5.5.1

            从官网(http://qt-project.org/downloads)下载相应平台的版本安装即可,路径设成默认(/Users/*/Qt5.5.1)即可

            安装完成需要将Qt5添加到环境变量~/.bash_profile         

vim ~/.bash_profile

将下面两行添加进去

PATH="/Users/*/Qt5.5.1/5.5/clang_64/bin:${PATH}" export PATH

3.安装SIP4.14

            下载地址:http://www.riverbankcomputing.com/software/sip/download            

tar -zxvf sip-4.17.tar.gz   cd sip-4.17python3 configure.py  make  && date # 加&&date是个人习惯,make成功会显示时间sudo make install  && date # 一定要加sudo

4.安装QScintilla/Qt4Qt5

                下载地址:http://www.riverbankcomputing.com/software/qscintilla/download

              QScintilla2 文件中有3个文件夹的内容要分别安装:Qt4Qt5,designer-Qt4Qt5和Python。

              Qt4Qt5文件夹要在PyQt之前安装,designer-Qt4Qt5和Python要在PyQt之后安装,顺序一定要注意!!

cd ./QScintilla-gpl-2.9.1/Qt4Qt5qmake qscintilla.pro make && datesudo make install && date

5.安装PyQt5.5.1

            下载地址:https://www.riverbankcomputing.com/software/pyqt/download5

            由于是安装在Python的site-packages里,所以要首先确定包的位置

python3Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 19 2015, 20:38:52) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> import site>>> site.getsitepackages()['/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages', '/Library/Frameworks/Python.framework/Versions/3.4/lib/site-python', '/Library/Python/3.4/site-packages']

        知道了位置开始编译

cd PyQt-gpl-5.5.1$python3 configure.py -q /Users/**/Qt5.5.1/5.5/clang_64/bin/qmake -d /Library/Python/3.4/site-packages/ #-q 后面的是qmake的位置,-d 后面是Python包的位置make && date

注意!!

我在执行make的时候出了一个这样的错误

/Users/Kallan/Documents/Python开发/PyQt-gpl-5.5.1/sip/QtPositioning/qgeolocation.sip:28:10: fatal error:       'qgeolocation.h' file not found#include <qgeolocation.h>         ^1 error generated.make[1]: *** [sipQtPositioningcmodule.o] Error 1make: *** [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

继续!

make cleanmake && datesudo make install && date

6.安装QScintilla/Python

cd /QScintilla-gpl-2.9.1/Pythonpython3 configure.py --pyqt=PyQt5 -d /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyQt5 --pyqt-sipdir=/Library/Frameworks/Python.framework/Versions/3.4/share/sip/PyQt5 -v /Library/Frameworks/Python.framework/Versions/3.4/share/sip/PyQt5make && datesudo make install && date

如果在Python里import不会报错,即代表安装成功,可继续往下进行

python3Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 19 2015, 20:38:52) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> import PyQt5.Qsci>>> exit()


7.安装QScintilla/designer-Qt4Qt5        

cd /QScintilla-gpl-2.9.1/designer-Qt4Qt5qmake designer.pro make && datesudo make install && date

8.安装Eric6

下载地址:http://sourceforge.net/projects/eric-ide/files/eric6/stable/

下载其中的eric6-6.1.1.tar主文件和eric6-i18n-zh_CN.GB2312-6.1.1.tar中文语言包。

将两个文件提取出来,将中文语音包的eric复制到主文件内合并

cd eric6-6.1.1sudo python3 install.py


spacer.gif

配置Eric6

1、选择Eric6-> preference -> Editor -> Autocompation。勾选所有选框;

spacer.gif

2.Editor -> QScintilla 。勾上左右的两个选框,然后在下面source中,选择from Document and API files;

spacer.gif

3.Editor -> APIs。勾选Complie APIs Autocompation,在Language中,选择python3。点面下面的Add from installed APIs按钮,选择住需要的.api文件。最后点击Compile APIs;

spacer.gif

4、Interface -> Interface。Language选择中文,重启生效。

spacer.gif

大功告成!
三、曾经遇到的问题
1.安装QScintilla designer-Qt4Qt5时报错!

root@kallan:/media/kallan/D盘/编程学习/python/QScintilla-gpl-2.9.1/designer-Qt4Qt5# qmake -qt5 designer.pro Project ERROR: Unknown module(s) in QT: designer

原因: Qt没有安装好
2.安装QScintilla Python时报错!

python3 configure.py --pyqt=PyQt5 -d /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyQt5 --pyqt-sipdir=/Library/Frameworks/Python.framework/Versions/3.4/share/sip/PyQt5 --qsci-sipdir=/Library/Frameworks/Python.framework/Versions/3.4/share/sip/PyQt5Error: Make sure you have a working sip on your PATH or use the --sip argumentto explicitly specify a working sip.

原因:没有安装SIP
3.安装QScintilla Python时报错!

python3 configure.py --pyqt=PyQt5Configuring QScintilla 2.9.1...QScintilla 2.9.1 is being used.The QScintilla .sip files will be installed in /usr/share/sip/PyQt5.The QScintilla module will be installed in/usr/lib/python3/dist-packages/PyQt5.PyQt 5.3.1 is being used.Qt 5.3.1 is being used.sip 4.16.2 is being used.The sip executable is /usr/bin/sip.The QScintilla module is being built with 'protected' redefined as 'public'.The QScintilla API file will be installed in /usr/share/qt5/qsci/api/python.Generating the C++ source for the Qsci module...Error: Unable to create the C++ code.

原因:安装顺序错误——先安装的PyQt5,而后安装的QScintilla Qt4Qt5
4.QScintilla的Python安装完成但是在Python中import时报错!

>>> import PyQt5.QsciTraceback (most recent call last):  File "<stdin>", line 1, in <module>ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyQt5/Qsci.so, 2): Library not loaded: @rpath/QtPrintSupport.framework/Versions/5/QtPrintSupport  Referenced from: /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyQt5/Qsci.so  Reason: image not found

5.安装Eric报错!

python3 install.pyChecking dependenciesPython Version: 3.4.4Found PyQt5Sorry, please install QScintilla2 andits PyQt5/PyQt4 wrapper.Error: dlopen(/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyQt5/Qsci.so, 2): Library not loaded: @rpath/QtPrintSupport.framework/Versions/5/QtPrintSupport  Referenced from: /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/PyQt5/Qsci.so  Reason: image not found

4和5问题的原因是一样的,QScintilla的Python没有安装成功






运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-164605-1-1.html 上篇帖子: 新款Macbook Air安装Windows8.1黑屏解决教程 下篇帖子: 老款macbookpro升级OSX10.11 Ei Captain那点事 开发平台
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表