ubuntu 16.04编译NodeMCU-pyFlasher

最近在捣鼓NodeMCU,中间各种折腾,下面记录一下编译固件烧录工具的过程。

首先安装依赖包:

$ sudo apt-get install python3-pip

$ sudo pip3 install --upgrade pip

$ sudo pip3 install wxpython

$ sudo apt-get install pyseria

安装wxpython的时候,如果遇到问题,参考 ubuntu 16.04在Python3上安装wxpython-4.0.3

下载代码

$ sudo apt-get install git

$ git clone https://github.com/marcelstoer/nodemcu-pyflasher.git

如果源代码下载存在问题,可以本站下载一份拷贝

点击这里下载

编译并运行

$ cd nodemcu-pyflasher

$ bash build.sh

$ python3 Main.py

ubuntu 16.04在Python3上安装wxpython-4.0.3

需要在ubuntu 16.04上安装Python3需要使用的wxpython-4.0.3,中间过程如下:

$ sudo apt-get install python3-pip

$ sudo apt-get install build-essential

$ sudo pip3 install --upgrade pip

$ sudo pip3 install wxpython

如果提示如下错误信息:

    checking for pkg-config... no
    checking for GTK+ - version >= 3.0.0... no
    *** A new enough version of pkg-config was not found.
    *** See http://pkgconfig.sourceforge.net
    configure: error:
    The development files for GTK+ were not found. For GTK+ 2, please
    ensure that pkg-config is in the path and that gtk+-2.0.pc is
    installed. For GTK+ 1.2 please check that gtk-config is in the path,
    and that the version is 1.2.3 or above. Also check that the
    libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
    --libs' are in the LD_LIBRARY_PATH or equivalent.
    
    Error running configure
    ERROR: failed building wxWidgets
    Traceback (most recent call last):
      File "build.py", line 1321, in cmd_build_wx
        wxbuild.main(wxDir(), build_options)
      File "/tmp/pip-build-i74kd49w/wxpython/buildtools/build_wxwidgets.py", line 375, in main
        "Error running configure")
      File "/tmp/pip-build-i74kd49w/wxpython/buildtools/build_wxwidgets.py", line 85, in exitIfError
        raise builder.BuildError(msg)
    buildtools.builder.BuildError: Error running configure
    Finished command: build_wx (0m2.471s)
    Finished command: build (0m2.471s)
    Command '"/usr/bin/python3" -u build.py build' failed with exit code 1.
    
    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-i74kd49w/wxpython/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-kx0e4kl4-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-i74kd49w/wxpython/

则执行如下命令:

$ sudo apt-get install build-essential libgtk-3-dev

如果出现如下错误信息:

    checking for GST... configure: WARNING: GStreamer 1.0 not available, falling back to 0.10
    checking for GST... configure: WARNING: GStreamer 0.10 not available, falling back to 0.8
    configure: error: GStreamer not available
    Error running configure
    ERROR: failed building wxWidgets
    Traceback (most recent call last):
      File "build.py", line 1321, in cmd_build_wx
        wxbuild.main(wxDir(), build_options)
      File "/tmp/pip-install-_6rbj1se/wxpython/buildtools/build_wxwidgets.py", line 375, in main
        "Error running configure")
      File "/tmp/pip-install-_6rbj1se/wxpython/buildtools/build_wxwidgets.py", line 85, in exitIfError
        raise builder.BuildError(msg)
    buildtools.builder.BuildError: Error running configure
    Finished command: build_wx (0m5.302s)
    Finished command: build (0m5.302s)
    Command '"/usr/bin/python3" -u build.py build' failed with exit code 1.
    
    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-_6rbj1se/wxpython/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-gkelw1g2/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-_6rbj1se/wxpython/

则执行如下命令:

$ sudo apt install libgstreamer-plugins-base1.0-dev

如果出现如下错误信息:

   ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp: In function ‘PyObject* meth_wxWebViewHistoryItem_GetUrl(PyObject*, PyObject*)’:
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:24:10: error: ‘::wxWebViewHistoryItem’ has not been declared
              ::wxWebViewHistoryItem *sipCpp;
              ^
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:24:34: error: ‘sipCpp’ was not declared in this scope
              ::wxWebViewHistoryItem *sipCpp;
                                      ^
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp: In function ‘PyObject* meth_wxWebViewHistoryItem_GetTitle(PyObject*, PyObject*)’:
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:58:10: error: ‘::wxWebViewHistoryItem’ has not been declared
              ::wxWebViewHistoryItem *sipCpp;
              ^
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:58:34: error: ‘sipCpp’ was not declared in this scope
              ::wxWebViewHistoryItem *sipCpp;
                                      ^
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp: In function ‘void release_wxWebViewHistoryItem(void*, int)’:
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:90:32: error: ‘wxWebViewHistoryItem’ in namespace ‘::’ does not name a type
         delete reinterpret_cast< ::wxWebViewHistoryItem *>(sipCppV);
                                    ^
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:90:53: error: expected ‘>’ before ‘*’ token
         delete reinterpret_cast< ::wxWebViewHistoryItem *>(sipCppV);
                                                         ^
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:90:53: error: expected ‘(’ before ‘*’ token
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:90:54: error: expected primary-expression before ‘>’ token
         delete reinterpret_cast< ::wxWebViewHistoryItem *>(sipCppV);
                                                          ^
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:90:64: error: expected ‘)’ before ‘;’ token
         delete reinterpret_cast< ::wxWebViewHistoryItem *>(sipCppV);
                                                                    ^
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp: In function ‘void* init_type_wxWebViewHistoryItem(sipSimpleWrapper*, PyObject*, PyObject*, PyObject**, PyObject**, PyObject**)’:
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:109:6: error: ‘::wxWebViewHistoryItem’ has not been declared
          ::wxWebViewHistoryItem *sipCpp = 0;
          ^
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:109:30: error: ‘sipCpp’ was not declared in this scope
          ::wxWebViewHistoryItem *sipCpp = 0;
                                  ^
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:127:27: error: expected type-specifier before ‘::’ token
                 sipCpp = new  ::wxWebViewHistoryItem(*url,*title);
                               ^
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:134:24: error: type ‘<type error>’ argument given to ‘delete’, expected pointer
                     delete sipCpp;
                            ^
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:143:18: error: ‘wxWebViewHistoryItem’ in namespace ‘::’ does not name a type
             const  ::wxWebViewHistoryItem* a0;
                      ^
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:145:114: error: ‘a0’ was not declared in this scope
             if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, NULL, sipUnused, "J9", sipType_wxWebViewHistoryItem, &a0))
                                                                                                                      ^
    ../../../../sip/cpp/sip_html2wxWebViewHistoryItem.cpp:148:27: error: expected type-specifier before ‘::’ token
                 sipCpp = new  ::wxWebViewHistoryItem(*a0);
                               ^
    
    ../../../../sip/cpp/sip_html2wxWebView.cpp:50:45: error: ‘wxWebView’ was not declared in this scope
         PyObject* _wxWebView_GetBackwardHistory(wxWebView* self)
                                                 ^
    ../../../../sip/cpp/sip_html2wxWebView.cpp:50:56: error: ‘self’ was not declared in this scope
         PyObject* _wxWebView_GetBackwardHistory(wxWebView* self)
                                                            ^
    ../../../../sip/cpp/sip_html2wxWebView.cpp:51:5: error: expected ‘,’ or ‘;’ before ‘{’ token
         {
         ^
    
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:18:1: error: expected class-name before ‘{’ token
     {
     ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:21:34: error: ‘wxWebViewHandler’ in namespace ‘::’ does not name a type
         sipwxWebViewHandler(const  ::wxWebViewHandler&);
                                      ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp: In constructor ‘sipwxWebViewHandler::sipwxWebViewHandler(const wxString&)’:
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:42:89: error: expected class-name before ‘(’ token
     sipwxWebViewHandler::sipwxWebViewHandler(const  ::wxString& scheme):  ::wxWebViewHandler(scheme), sipPySelf(0)
                                                                                             ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:42:89: error: expected ‘{’ before ‘(’ token
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp: At global scope:
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:42:97: error: expected constructor, destructor, or type conversion before ‘,’ token
     sipwxWebViewHandler::sipwxWebViewHandler(const  ::wxString& scheme):  ::wxWebViewHandler(scheme), sipPySelf(0)
                                                                                                     ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:42:108: error: expected constructor, destructor, or type conversion before ‘(’ token
     sipwxWebViewHandler::sipwxWebViewHandler(const  ::wxString& scheme):  ::wxWebViewHandler(scheme), sipPySelf(0)
                                                                                                                ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:47:51: error: ‘wxWebViewHandler’ in namespace ‘::’ does not name a type
     sipwxWebViewHandler::sipwxWebViewHandler(const  ::wxWebViewHandler& a0):  ::wxWebViewHandler(a0), sipPySelf(0)
                                                       ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp: In constructor ‘sipwxWebViewHandler::sipwxWebViewHandler(const int&)’:
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:47:93: error: expected class-name before ‘(’ token
     sipwxWebViewHandler::sipwxWebViewHandler(const  ::wxWebViewHandler& a0):  ::wxWebViewHandler(a0), sipPySelf(0)
                                                                                                 ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:47:93: error: expected ‘{’ before ‘(’ token
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp: At global scope:
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:47:97: error: expected constructor, destructor, or type conversion before ‘,’ token
     sipwxWebViewHandler::sipwxWebViewHandler(const  ::wxWebViewHandler& a0):  ::wxWebViewHandler(a0), sipPySelf(0)
                                                                                                     ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:47:108: error: expected constructor, destructor, or type conversion before ‘(’ token
     sipwxWebViewHandler::sipwxWebViewHandler(const  ::wxWebViewHandler& a0):  ::wxWebViewHandler(a0), sipPySelf(0)
                                                                                                                ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp: In member function ‘wxString sipwxWebViewHandler::GetName() const’:
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:65:19: error: ‘::wxWebViewHandler’ has not been declared
             return  ::wxWebViewHandler::GetName();
                       ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp: In function ‘PyObject* meth_wxWebViewHandler_GetFile(PyObject*, PyObject*, PyObject*)’:
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:99:10: error: ‘::wxWebViewHandler’ has not been declared
              ::wxWebViewHandler *sipCpp;
              ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:99:30: error: ‘sipCpp’ was not declared in this scope
              ::wxWebViewHandler *sipCpp;
                                  ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp: In function ‘PyObject* meth_wxWebViewHandler_GetName(PyObject*, PyObject*)’:
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:145:18: error: ‘wxWebViewHandler’ in namespace ‘::’ does not name a type
             const  ::wxWebViewHandler *sipCpp;
                      ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:147:91: error: ‘sipCpp’ was not declared in this scope
             if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_wxWebViewHandler, &sipCpp))
                                                                                               ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:154:66: error: ‘::wxWebViewHandler’ has not been declared
                 sipRes = new  ::wxString((sipSelfWasArg ? sipCpp-> ::wxWebViewHandler::GetName() : sipCpp->GetName()));
                                                                      ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp: In function ‘void release_wxWebViewHandler(void*, int)’:
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:180:36: error: ‘wxWebViewHandler’ in namespace ‘::’ does not name a type
             delete reinterpret_cast< ::wxWebViewHandler *>(sipCppV);
                                        ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:180:53: error: expected ‘>’ before ‘*’ token
             delete reinterpret_cast< ::wxWebViewHandler *>(sipCppV);
                                                         ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:180:53: error: expected ‘(’ before ‘*’ token
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:180:54: error: expected primary-expression before ‘>’ token
             delete reinterpret_cast< ::wxWebViewHandler *>(sipCppV);
                                                          ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:180:64: error: expected ‘)’ before ‘;’ token
             delete reinterpret_cast< ::wxWebViewHandler *>(sipCppV);
                                                                    ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp: In function ‘void* init_type_wxWebViewHandler(sipSimpleWrapper*, PyObject*, PyObject*, PyObject**, PyObject**, PyObject**)’:
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:234:18: error: ‘wxWebViewHandler’ in namespace ‘::’ does not name a type
             const  ::wxWebViewHandler* a0;
                      ^
    ../../../../sip/cpp/sip_html2wxWebViewHandler.cpp:236:110: error: ‘a0’ was not declared in this scope
             if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, NULL, sipUnused, "J9", sipType_wxWebViewHandler, &a0))
                                                                                                                  ^
    
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:18:1: error: expected class-name before ‘{’ token
     {
     ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:21:36: error: ‘wxWebViewFSHandler’ in namespace ‘::’ does not name a type
         sipwxWebViewFSHandler(const  ::wxWebViewFSHandler&);
                                        ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp: In constructor ‘sipwxWebViewFSHandler::sipwxWebViewFSHandler(const wxString&)’:
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:42:95: error: expected class-name before ‘(’ token
     sipwxWebViewFSHandler::sipwxWebViewFSHandler(const  ::wxString& scheme):  ::wxWebViewFSHandler(scheme), sipPySelf(0)
                                                                                                   ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:42:95: error: expected ‘{’ before ‘(’ token
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp: At global scope:
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:42:103: error: expected constructor, destructor, or type conversion before ‘,’ token
     sipwxWebViewFSHandler::sipwxWebViewFSHandler(const  ::wxString& scheme):  ::wxWebViewFSHandler(scheme), sipPySelf(0)
                                                                                                           ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:42:114: error: expected constructor, destructor, or type conversion before ‘(’ token
     sipwxWebViewFSHandler::sipwxWebViewFSHandler(const  ::wxString& scheme):  ::wxWebViewFSHandler(scheme), sipPySelf(0)
                                                                                                                      ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:47:55: error: ‘wxWebViewFSHandler’ in namespace ‘::’ does not name a type
     sipwxWebViewFSHandler::sipwxWebViewFSHandler(const  ::wxWebViewFSHandler& a0):  ::wxWebViewFSHandler(a0), sipPySelf(0)
                                                           ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp: In constructor ‘sipwxWebViewFSHandler::sipwxWebViewFSHandler(const int&)’:
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:47:101: error: expected class-name before ‘(’ token
     sipwxWebViewFSHandler::sipwxWebViewFSHandler(const  ::wxWebViewFSHandler& a0):  ::wxWebViewFSHandler(a0), sipPySelf(0)
                                                                                                         ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:47:101: error: expected ‘{’ before ‘(’ token
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp: At global scope:
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:47:105: error: expected constructor, destructor, or type conversion before ‘,’ token
     sipwxWebViewFSHandler::sipwxWebViewFSHandler(const  ::wxWebViewFSHandler& a0):  ::wxWebViewFSHandler(a0), sipPySelf(0)
                                                                                                             ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:47:116: error: expected constructor, destructor, or type conversion before ‘(’ token
     sipwxWebViewFSHandler::sipwxWebViewFSHandler(const  ::wxWebViewFSHandler& a0):  ::wxWebViewFSHandler(a0), sipPySelf(0)
                                                                                                                        ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp: In member function ‘wxFSFile* sipwxWebViewFSHandler::GetFile(const wxString&)’:
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:65:19: error: ‘::wxWebViewFSHandler’ has not been declared
             return  ::wxWebViewFSHandler::GetFile(uri);
                       ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp: In member function ‘wxString sipwxWebViewFSHandler::GetName() const’:
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:80:19: error: ‘::wxWebViewFSHandler’ has not been declared
             return  ::wxWebViewFSHandler::GetName();
                       ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp: In function ‘PyObject* meth_wxWebViewFSHandler_GetFile(PyObject*, PyObject*, PyObject*)’:
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:99:10: error: ‘::wxWebViewFSHandler’ has not been declared
              ::wxWebViewFSHandler *sipCpp;
              ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:99:32: error: ‘sipCpp’ was not declared in this scope
              ::wxWebViewFSHandler *sipCpp;
                                    ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:112:50: error: ‘::wxWebViewFSHandler’ has not been declared
                 sipRes = (sipSelfWasArg ? sipCpp-> ::wxWebViewFSHandler::GetFile(*uri) : sipCpp->GetFile(*uri));
                                                      ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp: In function ‘void* cast_wxWebViewFSHandler(void*, const sipTypeDef*)’:
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:134:6: error: ‘::wxWebViewFSHandler’ has not been declared
          ::wxWebViewFSHandler *sipCpp = reinterpret_cast< ::wxWebViewFSHandler *>(sipCppV);
          ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:134:28: error: ‘sipCpp’ was not declared in this scope
          ::wxWebViewFSHandler *sipCpp = reinterpret_cast< ::wxWebViewFSHandler *>(sipCppV);
                                ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:134:57: error: ‘wxWebViewFSHandler’ in namespace ‘::’ does not name a type
          ::wxWebViewFSHandler *sipCpp = reinterpret_cast< ::wxWebViewFSHandler *>(sipCppV);
                                                             ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:134:76: error: expected ‘>’ before ‘*’ token
          ::wxWebViewFSHandler *sipCpp = reinterpret_cast< ::wxWebViewFSHandler *>(sipCppV);
                                                                                ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:134:76: error: expected ‘(’ before ‘*’ token
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:134:77: error: expected primary-expression before ‘>’ token
          ::wxWebViewFSHandler *sipCpp = reinterpret_cast< ::wxWebViewFSHandler *>(sipCppV);
                                                                                 ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:134:87: error: expected ‘)’ before ‘;’ token
          ::wxWebViewFSHandler *sipCpp = reinterpret_cast< ::wxWebViewFSHandler *>(sipCppV);
                                                                                           ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:137:31: error: ‘wxWebViewHandler’ in namespace ‘::’ does not name a type
             return static_cast< ::wxWebViewHandler *>(sipCpp);
                                   ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:137:48: error: expected ‘>’ before ‘*’ token
             return static_cast< ::wxWebViewHandler *>(sipCpp);
                                                    ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:137:48: error: expected ‘(’ before ‘*’ token
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:137:49: error: expected primary-expression before ‘>’ token
             return static_cast< ::wxWebViewHandler *>(sipCpp);
                                                     ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:137:58: error: expected ‘)’ before ‘;’ token
             return static_cast< ::wxWebViewHandler *>(sipCpp);
                                                              ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp: In function ‘void release_wxWebViewFSHandler(void*, int)’:
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:152:36: error: ‘wxWebViewFSHandler’ in namespace ‘::’ does not name a type
             delete reinterpret_cast< ::wxWebViewFSHandler *>(sipCppV);
                                        ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:152:55: error: expected ‘>’ before ‘*’ token
             delete reinterpret_cast< ::wxWebViewFSHandler *>(sipCppV);
                                                           ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:152:55: error: expected ‘(’ before ‘*’ token
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:152:56: error: expected primary-expression before ‘>’ token
             delete reinterpret_cast< ::wxWebViewFSHandler *>(sipCppV);
                                                            ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:152:66: error: expected ‘)’ before ‘;’ token
             delete reinterpret_cast< ::wxWebViewFSHandler *>(sipCppV);
                                                                      ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp: In function ‘void* init_type_wxWebViewFSHandler(sipSimpleWrapper*, PyObject*, PyObject*, PyObject**, PyObject**, PyObject**)’:
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:206:18: error: ‘wxWebViewFSHandler’ in namespace ‘::’ does not name a type
             const  ::wxWebViewFSHandler* a0;
                      ^
    ../../../../sip/cpp/sip_html2wxWebViewFSHandler.cpp:208:112: error: ‘a0’ was not declared in this scope
             if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, NULL, sipUnused, "J9", sipType_wxWebViewFSHandler, &a0))
                                                                                                                    ^
    
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:24:1: error: expected class-name before ‘{’ token
     {
     ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:27:34: error: ‘wxWebViewFactory’ in namespace ‘::’ does not name a type
         sipwxWebViewFactory(const  ::wxWebViewFactory&);
                                      ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:35:8: error: ‘wxWebView’ in namespace ‘::’ does not name a type
          ::wxWebView* Create( ::wxWindow*, ::wxWindowID,const  ::wxString&,const  ::wxPoint&,const  ::wxSize&,long,const  ::wxString&);
            ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:36:8: error: ‘wxWebView’ in namespace ‘::’ does not name a type
          ::wxWebView* Create();
            ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp: In constructor ‘sipwxWebViewFactory::sipwxWebViewFactory()’:
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:48:64: error: expected class-name before ‘(’ token
     sipwxWebViewFactory::sipwxWebViewFactory():  ::wxWebViewFactory(), sipPySelf(0)
                                                                    ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:48:64: error: expected ‘{’ before ‘(’ token
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp: At global scope:
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:48:65: error: expected unqualified-id before ‘)’ token
     sipwxWebViewFactory::sipwxWebViewFactory():  ::wxWebViewFactory(), sipPySelf(0)
                                                                     ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:48:77: error: expected constructor, destructor, or type conversion before ‘(’ token
     sipwxWebViewFactory::sipwxWebViewFactory():  ::wxWebViewFactory(), sipPySelf(0)
                                                                                 ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:53:51: error: ‘wxWebViewFactory’ in namespace ‘::’ does not name a type
     sipwxWebViewFactory::sipwxWebViewFactory(const  ::wxWebViewFactory& a0):  ::wxWebViewFactory(a0), sipPySelf(0)
                                                       ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp: In constructor ‘sipwxWebViewFactory::sipwxWebViewFactory(const int&)’:
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:53:93: error: expected class-name before ‘(’ token
     sipwxWebViewFactory::sipwxWebViewFactory(const  ::wxWebViewFactory& a0):  ::wxWebViewFactory(a0), sipPySelf(0)
                                                                                                 ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:53:93: error: expected ‘{’ before ‘(’ token
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp: At global scope:
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:53:97: error: expected constructor, destructor, or type conversion before ‘,’ token
     sipwxWebViewFactory::sipwxWebViewFactory(const  ::wxWebViewFactory& a0):  ::wxWebViewFactory(a0), sipPySelf(0)
                                                                                                     ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:53:108: error: expected constructor, destructor, or type conversion before ‘(’ token
     sipwxWebViewFactory::sipwxWebViewFactory(const  ::wxWebViewFactory& a0):  ::wxWebViewFactory(a0), sipPySelf(0)
                                                                                                                ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:63:4: error: ‘wxWebView’ in namespace ‘::’ does not name a type
      ::wxWebView* sipwxWebViewFactory::Create( ::wxWindow*parent, ::wxWindowID id,const  ::wxString& url,const  ::wxPoint& pos,const  ::wxSize& size,long style,const  ::wxString& name)
        ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:78:4: error: ‘wxWebView’ in namespace ‘::’ does not name a type
      ::wxWebView* sipwxWebViewFactory::Create()
        ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp: In function ‘PyObject* meth_wxWebViewFactory_Create(PyObject*, PyObject*, PyObject*)’:
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:108:10: error: ‘::wxWebViewFactory’ has not been declared
              ::wxWebViewFactory *sipCpp;
              ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:108:30: error: ‘sipCpp’ was not declared in this scope
              ::wxWebViewFactory *sipCpp;
                                  ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:112:14: error: ‘::wxWebView’ has not been declared
                  ::wxWebView*sipRes;
                  ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:112:26: error: ‘sipRes’ was not declared in this scope
                  ::wxWebView*sipRes;
                              ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:136:37: error: ‘wxWebViewDefaultURLStr’ was not declared in this scope
             const  ::wxString& urldef = wxWebViewDefaultURLStr;
                                         ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:146:38: error: ‘wxWebViewNameStr’ was not declared in this scope
             const  ::wxString& namedef = wxWebViewNameStr;
                                          ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:149:10: error: ‘::wxWebViewFactory’ has not been declared
              ::wxWebViewFactory *sipCpp;
              ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:149:30: error: ‘sipCpp’ was not declared in this scope
              ::wxWebViewFactory *sipCpp;
                                  ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:163:14: error: ‘::wxWebView’ has not been declared
                  ::wxWebView*sipRes;
                  ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:163:26: error: ‘sipRes’ was not declared in this scope
                  ::wxWebView*sipRes;
                              ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp: In function ‘void* cast_wxWebViewFactory(void*, const sipTypeDef*)’:
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:199:6: error: ‘::wxWebViewFactory’ has not been declared
          ::wxWebViewFactory *sipCpp = reinterpret_cast< ::wxWebViewFactory *>(sipCppV);
          ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:199:26: error: ‘sipCpp’ was not declared in this scope
          ::wxWebViewFactory *sipCpp = reinterpret_cast< ::wxWebViewFactory *>(sipCppV);
                              ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:199:55: error: ‘wxWebViewFactory’ in namespace ‘::’ does not name a type
          ::wxWebViewFactory *sipCpp = reinterpret_cast< ::wxWebViewFactory *>(sipCppV);
                                                           ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:199:72: error: expected ‘>’ before ‘*’ token
          ::wxWebViewFactory *sipCpp = reinterpret_cast< ::wxWebViewFactory *>(sipCppV);
                                                                            ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:199:72: error: expected ‘(’ before ‘*’ token
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:199:73: error: expected primary-expression before ‘>’ token
          ::wxWebViewFactory *sipCpp = reinterpret_cast< ::wxWebViewFactory *>(sipCppV);
                                                                             ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:199:83: error: expected ‘)’ before ‘;’ token
          ::wxWebViewFactory *sipCpp = reinterpret_cast< ::wxWebViewFactory *>(sipCppV);
                                                                                       ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp: In function ‘void release_wxWebViewFactory(void*, int)’:
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:217:36: error: ‘wxWebViewFactory’ in namespace ‘::’ does not name a type
             delete reinterpret_cast< ::wxWebViewFactory *>(sipCppV);
                                        ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:217:53: error: expected ‘>’ before ‘*’ token
             delete reinterpret_cast< ::wxWebViewFactory *>(sipCppV);
                                                         ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:217:53: error: expected ‘(’ before ‘*’ token
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:217:54: error: expected primary-expression before ‘>’ token
             delete reinterpret_cast< ::wxWebViewFactory *>(sipCppV);
                                                          ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:217:64: error: expected ‘)’ before ‘;’ token
             delete reinterpret_cast< ::wxWebViewFactory *>(sipCppV);
                                                                    ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp: In function ‘void* init_type_wxWebViewFactory(sipSimpleWrapper*, PyObject*, PyObject*, PyObject**, PyObject**, PyObject**)’:
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:255:18: error: ‘wxWebViewFactory’ in namespace ‘::’ does not name a type
             const  ::wxWebViewFactory* a0;
                      ^
    ../../../../sip/cpp/sip_html2wxWebViewFactory.cpp:257:110: error: ‘a0’ was not declared in this scope
             if (sipParseKwdArgs(sipParseErr, sipArgs, sipKwds, NULL, sipUnused, "J9", sipType_wxWebViewFactory, &a0))
                                                                                                                  ^
    
    Waf: Leaving directory `/tmp/pip-install-uc7g8zv4/wxpython/build/waf/3.5/gtk3'
    Build failed
     -> task in '_html2' failed with exit status 1 (run with -v to display more information)
     -> task in '_html2' failed with exit status 1 (run with -v to display more information)
     -> task in '_html2' failed with exit status 1 (run with -v to display more information)
     -> task in '_html2' failed with exit status 1 (run with -v to display more information)
     -> task in '_html2' failed with exit status 1 (run with -v to display more information)
    Command '"/usr/bin/python3" /tmp/pip-install-uc7g8zv4/wxpython/bin/waf-2.0.7 --wx_config=/tmp/pip-install-uc7g8zv4/wxpython/build/wxbld/gtk3/wx-config --gtk3 --python="/usr/bin/python3" --out=build/waf/3.5/gtk3 configure build ' failed with exit code 1.
    Finished command: build_py (4m1.752s)
    Finished command: build (6m9.232s)
    Command '"/usr/bin/python3" -u build.py build' failed with exit code 1.

则执行如下命令(显然是编译脚本忘记检查依赖项导致的):

$ sudo apt-get install libwebkitgtk-3.0-dev

参考链接


macOS High Sierra(10.13.6)解决"Error: Running Homebrew as root is extremely dangerous and no longer supported."

macOS High Sierra(10.13.6)版本上,使用Homebrew安装python2的时候出现如下问题:

$ brew install python2
Warning: python@2 2.7.15_1 is already installed, it's just not linked
You can use `brew link python@2` to link this version.

$ brew link python@2
Linking /usr/local/Cellar/python@2/2.7.15_1... Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

$ sudo brew link python@2
Password:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.

网上的解决方法是把整个/usr/local的所有者修改为当前用户,但是新版本的macOS High Sierra(10.13.6)已经不支持这样操作了,如下:

$ sudo chown -R `whoami` /usr/local
chown: /usr/local: Operation not permitted

那么解决方法如下:

$ sudo chown -R `whoami` /usr/local/Homebrew/

$ sudo chown -R $(whoami) $(brew --prefix)/*

$ sudo mkdir /usr/local/Frameworks

$ sudo chown -R `whoami` /usr/local/Frameworks/

完成上面的操作后,我们可以看到已经能成功操作了:

$ brew link python@2
Linking /usr/local/Cellar/python@2/2.7.15_1... 5 symlinks created

#如果曾经安装过pip可能导致pip被链接到系统的python版本,可是系统目录上各种无权限,因此我们移除已经安装的pip,重新链接pip到brew安装的python

$ sudo rm -rf /usr/local/bin/pip

$ brew reinstall python2

参考链接