環境:fedora 23 x86_64
1. 使用 python 2.7 時安裝 ride 的錯誤
直接用命令裝的 ride,裝的是 ride 1.5.2.1。安裝沒問題,但是運行 ride.py 的時候會提示 wxPython 版本的問題。
使用 dnf 默認裝的 wxPython x86_64 3.0.2.0-8.fc23 會提示不能用,打不開 ride.py。並提示下面的鏈接
https://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/,我現在所使用的 http://git.oschina.net/danacai/wxwidgets2-8-2-8-12-1
fedora 源里 最接近的 rpm 包 wxPython-2.8.12.0-8.fc21.x86_64.rpm 可以使用 dnf 正常安裝,ride.py 可以打開,但是也是提示兼容性問題,讓使用上面的鏈接,只能用上面的鏈接從源碼安裝了。
1.1 安裝 wxwidgets2.8-2.8.12.1 時的錯誤
1.1.1 gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1:
需要安裝 sudo dnf install redhat-rpm-config
ref: https://bugs.launchpad.net/openstack-gate/+bug/1424582
1.1.2 src/helpers.cpp:15:20: fatal error: Python.h: No such file or directory
需要安裝 python-devel
ref: http://weerapurage.org/blog/2013/11/12/compile-wxpython-2-dot-9-5-dot-0-in-linux/
1.2 在 wxPython 目錄 里使用 python setup.py install 安裝 wxPython 時:
1.2.1 /wxPython_int.h:19:19: wx/wx.h: No such file or directory
需要配置 LD_LIBRARY_PATH 將當前用戶和root用戶都配置一下,或者在全局配置。默認wxwidgets2.8-2.8.12.1 的這個源碼時裝載 /usr/local/lib里的,因此要在LD_LIBRARY_PATH 里加上這個路徑,
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/lib
export LD_LIBRARY_PATH
1.2.2 fatal error: wx/stc/stc.h: No such file or directory
在 contrib 目錄下運行,加載 contrib 模塊,並的 configure 時 加載 --with-gtk --enable-gtk2 --enable-unicode
./configure --with-gtk --enable-gtk2 --enable-unicode make sudo make install # Install wxWidgets contrib modules. cd contrib/ make sudo make install
ref: http://forum.tinycorelinux.net/index.php?topic=16717.0
1.2.3 format not a string literal and no format arguments [-Wformat-security]
PyErr_Format(PyExc_RuntimeError, mesg);
通過
grep -R "PyErr_Format(PyExc_RuntimeError, mesg);" ./
可以看到源碼中有很多文件有這個問題
進入相應目錄通過
sed -i 's/PyErr_Format(PyExc_RuntimeError, mesg);/PyErr_Format(PyExc_RuntimeError, "%s", mesg);/g' *.cpp
進行批量替換為 PyErr_Format(PyExc_RuntimeError, "%s", mesg);
https://www.cyberciti.biz/faq/unix-linux-replace-string-words-in-many-files/
1.2.4 error: 'wxGLCanvas' was not declared in this scope
嘗試在 configure wxwidgets2.8-2.8.12.1 的時候 打開 opengl 支持,或者 使用 python setup.py install BUILD_GLCANVAS=0 禁用它,我這里使用的后者。
ref: http://wxpython-users.1045709.n5.nabble.com/Source-Compilation-errors-td2369170.html
2. 最初使用 python 3.4 時的錯誤
默認使用 pip install 安裝的 robotframework-selenium2library 不支持 python 3.x,所以 使用
pip install -U https://github.com/HelioGuilherme66/robotframework-selenium2library/archive/v1.8.0b3.tar.gz
安裝了 beta 版,但是后面裝 ride 的時候還是會有問題,如: NameError: name 'execfile' is not defined
ref: https://github.com/robotframework/Selenium2Library/issues/573
https://github.com/HelioGuilherme66/robotframework-selenium2library/tree/v1.8.0b3
https://github.com/robotframework/RIDE/issues/1587
最終還是切換回了 python 2.7 的安裝環境。
