Dec 18, 2015 Python 中文版
To understand the performance of Python applications, developers can use some useful tools, such as cProfie and RunSnakeRun. However, it is a little bit difficult when I tried to get RunSnakeRun working on Mac OS X. Thus, this article is going to record how I install and make RunSnakeRun work.
There are four packages that we have to install: RunSnakeRun, SquareMap, wxPython, wxmac. First, let’s use pip to install RunSnakeRun and SquareMap. To install:
# Search packages
pip search SquareMap RunSnakeRun
# Install packages
pip install SquareMap RunSnakeRun
Installing wxPython and wxWidgets ( wxmac ) is the most frustrated part to me. Luckily, Mac users can use Homebrew to install wxPython and wxmac. To install:
# Search packages
brew search wxPython wxmac
# Install packages
brew install wxPython wxmac
To run RunSnakeRun, just open the terminal and type:
runsnake
# or runsnake32
After executed the command, you can see the RunSnakeRun’s UI pop up, and then import the files that you want to analyze.
(1.) Homebrew will install packages to the directory: /usr/local/Cellar. If you are using system Python, it won’t find the modules that you installed via Homebrew. And the error message should be:
ImportError: No module named wx
Thus, we have to let the system Python know where the modules are. Open the terminal and change the directory to /Library/Python/2.7/site-packages, and create a text file named wx.pth. Then, put the path of wxPython module into it. The path should be:
/usr/local/Cellar/wxpython/3.0.2.0/lib/python2.7/site-packages/wx-3.0-osx_cocoa
Now, the system Python can find the wxPython module.
(2.) When you executed runsnake, an error message showed:
ImportError: dlopen(/usr/local/Cellar/wxpython/3.0.2.0/lib/python2.7/site-packages/wx-3.0-osx_cocoa/wx/_core_.so, 2): no suitable image found.
Did find: /usr/local/Cellar/wxpython/3.0.2.0/lib/python2.7/site-packages/wx-3.0-osx_cocoa/wx/_core_.so: mach-o, but wrong architecture
You can try run runsnake32.
If you have any suggestions, questions or even find some typos, feel free to contact me. Thank you! :)
zeckli.devforgalaxy@gmail.com © 2015-2019 zeckli, thanks to Jekyll and GitHub.