IBridgePy not working on MacBook Air

Course Name: Futures Trading: Concepts & Strategies, Section No: 27, Unit No: 4, Unit type: Notebook

I am using a M1 macbook air and have installed python with homebrew as per videos

I have installed python3.9 using home-brew and followed all the instructions as per IBridgePy videos. When I run the RUN_ME.py file I get the following error:

ImportError: dlopen(/Users/redwall/Desktop/IBridgePy_Mac_Python39_64/IBridgePy/IBCpp.so, 2): no suitable image found.  Did find:
    /Users/redwall/Desktop/IBridgePy_Mac_Python39_64/IBridgePy/IBCpp.so: mach-o, but wrong architecture
    /Users/redwall/Desktop/IBridgePy_Mac_Python39_64/IBridgePy/IBCpp.so: mach-o, but wrong architecture


When I run file$(which python) I get the following:

/usr/bin/python: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
/usr/bin/python (for architecture x86_64):  Mach-O 64-bit executable x86_64
/usr/bin/python (for architecture arm64e):  Mach-O 64-bit executable arm64e

Hi Gabriele,



The error seems to be due to a conflict between the 32-bit and 64-bit version of the python executable. The IBridgePy seems to be looking for the 64-bit version of python, but the default python version on your system seems to run the 32-bit version.



To confirm, could you please share the output of the following command?

python -c 'import sys; print(sys.maxsize)' 


If the answer is 9223372036854775807 then the system is running the 64-bit python. If not, then you can try the solution mentioned in this answer. It's an old Stackoverflow answer for python version 2.x, but the problem seems to be the same.

Thanks Gaurav for taking the time to look into this. I have run what you asked and I do get the following output:

 

redwall@Gabrieles-Air ~ % python -c 'import sys; print(sys.maxsize)'

9223372036854775807

I guess in this case it is not than applicable to old stackoverflow answer. Could it be that ithe arm64e architecture is causing the issue and it should run the x86_64?

Apologies not sure if the above makes sense as I am not super familiar with python architectures.

Hi Gabriele


your output suggests that the python is running on the 64 bit architecture.

The x86 is equivalent to 32 bit programs.

Maybe the arm architecture is not being recognised by IBridgePy. Let me check this aspect and get back to you.

In the meantime, please share the full error stack when you try to run python RUN_ME.py.

Thanks.

Thanks Gaurav this is the full error stack:

redwall@Gabrieles-Air IBridgePy_Mac_Python39_64 % python3.9 RUN_ME.py

Traceback (most recent call last):

  File "/Users/redwall/Desktop/IBridgePy_Mac_Python39_64/RUN_ME.py", line 16, in <module>

    from configuration import run_me

  File "/Users/redwall/Desktop/IBridgePy_Mac_Python39_64/configuration.py", line 25, in <module>

    from Config.config_defs import UserConfig

  File "/Users/redwall/Desktop/IBridgePy_Mac_Python39_64/Config/config_defs.py", line 10, in <module>

    from IBridgePy.MarketManagerBase import setup_services

  File "/Users/redwall/Desktop/IBridgePy_Mac_Python39_64/IBridgePy/MarketManagerBase.py", line 6, in <module>

    import broker_service_factory

  File "/Users/redwall/Desktop/IBridgePy_Mac_Python39_64/broker_service_factory/__init__.py", line 1, in <module>

    from .BrokerService import BrokerService

  File "/Users/redwall/Desktop/IBridgePy_Mac_Python39_64/broker_service_factory/BrokerService.py", line 12, in <module>

    from IBridgePy.IbridgepyTools import stripe_exchange_primaryExchange_from_security, choose_whatToShow

  File "/Users/redwall/Desktop/IBridgePy_Mac_Python39_64/IBridgePy/IbridgepyTools.py", line 28, in <module>

    from IBridgePy import IBCpp

ImportError: dlopen(/Users/redwall/Desktop/IBridgePy_Mac_Python39_64/IBridgePy/IBCpp.so, 2): no suitable image found.  Did find:

/Users/redwall/Desktop/IBridgePy_Mac_Python39_64/IBridgePy/IBCpp.so: mach-o, but wrong architecture

/Users/redwall/Desktop/IBridgePy_Mac_Python39_64/IBridgePy/IBCpp.so: mach-o, but wrong architecture

Hi Gabriele,



Could you try the lipo command? Link to StackOverflow post.



It is recommended you do that in a conda environment.



Let me know how that works out for you!