折騰來一下午,遇到了好多坑
坑
1.不要用pip 下載wxpython
2.不要用mac自帶的python
3.不要自己下載wxpython
步驟:
1. 安裝homebrew,
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2. 通過homebrew安裝python2.6或2.7, 理由是robotframework ride只支持2.6-2.7版本, 詳情請看 https://github.com/robotframework/RIDE/wiki/Installation-Instructions
可以通過brew search python 命令查詢可以下載的python版本,然后在根據具體名稱下載 brew install python2
3. 配置~/.bash_profile 文件, 將brew 下載的python配置到bash_profile文件中,正常目錄如下:
/usr/local/Cellar/python/2.7.13_1/bin
4. 然后通過pip下載robotframework-ride
pip install robotframework-ride
5. 通過brew下載wxpython, brew下載的默認是最新的穩定版, 目前是
wxpython: stable 3.0.2.0 (bottled)
此時執行ride.py會報錯
Wrong wxPython version. You need to install wxPython 2.8.12.1 with unicode support to run RIDE. wxPython 2.8.12.1 can be downloaded from http://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/
為了解決這個,網上很多方法都是要去下載安裝2.8.12.1版本, 各種安裝方法最后都不可以,解決辦法就是修改ride所支持的版本范圍,加上3.0版本就可以了,是參考:
http://widerin.net/blog/install-robot-framework-ride-through-homebrew/
找到當前python使用的site-packages目錄, 如何查找請在python命令下輸入以下命令就可以獲得
import site; site.getsitepackages()
/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
找到robotide 文件夾下的__init__.py 文件, 增加3.0支持
try: import wxversion from wxversion import VersionError if sys.platform == 'darwin': # CAN NOT IMPORT IS_MAC AS THERE IS A wx IMPORT supported_versions.append("2.9") supported_versions.append("3.0") wxversion.select(supported_versions) import wx
然后重新執行ride.py就大功告成了!
親測有效!