Debug IBridgePy on Mac

It is very common to see the following error when IBridgePy runs on Mac.
from IBridgePy import IBCpp
ImportError: dynamic module does not define module export function (PyInit_IBCpp)
The following steps will be helpful to solve the issue.
Step 1. Understand what IBridgePy you have downloaded.
As of 20190817, there are three IBridgePy versions:
IBridgePy_Mac_Anaconda27_64: IBridgePy is running on top of Anaconda python 2.7, 64-bit.
IBridgePy_Mac_Python27_64: IBridgePy is running on plain python 2.7, 64-bit, without Anaconda
IBridgePy_Mac_Python37_64: IBridgePy is running on plain python 3.7, 64-bit, without Anaconda
Step 2. Find what default python you are using, assuming you are not using IDE(Spyder, PyCharm, etc.)
$ which python   —–>find the default python version

If you see “/anaconda2/bin/python”, it means you are using Anaconda Python2.x
$ python    —–> Open python in command line

Python 2.7.14 |Anaconda, Inc.| (default, Dec  7 2017, 11:07:58)

[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin

Type “help”, “copyright”, “credits” or “license” for more information.

>>> —–> It confirms that you are using Anaconda Python 2.7.14

Step 3. Specify a python to run IBridgePy if you really want to
step 3.1 Go to the IBridgePy directory by “$ cd xx/xx/IBridgePy/”
step 3.2 Specify a python to run by ” $ /usr/bin/python RUN_ME.py”, assuming the native python locates at /usr/bin/python
Or you can specify Anaconda python to run by ” $ /anaconda2/bin/python RUN_ME.py”
Step 4. Check Python location if you are NOT using Anaconda
Make sure that python framework comes from /System/Library/Frameworks/Python.framework/Versions/2.7/Python

1 thought on “Debug IBridgePy on Mac”

  1. Pingback: Tutorial: Migrating from Quantopian to IBridgePy - Easiest Python Platform to Live Trade with Interactive Brokers

Leave a Comment