2

I'm trying to set up IBM MQ and pymqi on my macbook. MQ is done via docker, no issues there. I've installed the IBM MQ from https://developer.ibm.com/messaging/2019/02/05/ibm-mq-macos-toolkit-for-developers/ and followed the instructions. I pip installed pymqi with no issues after that.

But when simply running import pymqi I get

ImportError: dlopen(/Users/.../Library/Python/2.7/lib/python/site-packages/pymqi/pymqe.so, 2): Library not loaded: @rpath/libmqic_r.dylib

I've been on this for a day now trying all manner of linking, copying, permissions of files, setting env vars etc. No suggestions seem to work despite it being quite a common issue (looking at google results at least).

libmqic_r.dylib is available in two locations including /opt/mqm/lib64

otool output for this is below which I notice does not have LC_RPATH but I don't really understand it... i'm relatively new to python

libmqic_r.dylib:
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
 0xfeedfacf 16777223          3  0x00           6    14        928 0x00100085
Load command 0
      cmd LC_SEGMENT_64
  cmdsize 312
  segname __TEXT
   vmaddr 0x0000000000000000
   vmsize 0x0000000000001000
  fileoff 0
 filesize 4096
  maxprot 0x00000007
 initprot 0x00000005
   nsects 3
    flags 0x0
Section
  sectname __text
   segname __TEXT
      addr 0x00000000000006d0
      size 0x000000000000088d
    offset 1744
     align 2^4 (16)
    reloff 0
    nreloc 0
     flags 0x80000400
 reserved1 0
 reserved2 0
Section
  sectname __cstring
   segname __TEXT
      addr 0x0000000000000f5d
      size 0x000000000000004d
    offset 3933
     align 2^0 (1)
    reloff 0
    nreloc 0
     flags 0x00000002
 reserved1 0
 reserved2 0
Section
  sectname __unwind_info
   segname __TEXT
      addr 0x0000000000000fac
      size 0x0000000000000048
    offset 4012
     align 2^2 (4)
    reloff 0
    nreloc 0
     flags 0x00000000
 reserved1 0
 reserved2 0
Load command 1
      cmd LC_SEGMENT_64
  cmdsize 152
  segname __DATA
   vmaddr 0x0000000000001000
   vmsize 0x0000000000001000
  fileoff 4096
 filesize 4096
  maxprot 0x00000007
 initprot 0x00000003
   nsects 1
    flags 0x0
Section
  sectname __got
   segname __DATA
      addr 0x0000000000001000
      size 0x0000000000000010
    offset 4096
     align 2^3 (8)
    reloff 0
    nreloc 0
     flags 0x00000006
 reserved1 0 (index into indirect symbol table)
 reserved2 0
Load command 2
      cmd LC_SEGMENT_64
  cmdsize 72
  segname __LINKEDIT
   vmaddr 0x0000000000002000
   vmsize 0x0000000000003000
  fileoff 8192
 filesize 8672
  maxprot 0x00000007
 initprot 0x00000001
   nsects 0
    flags 0x0
Load command 3
          cmd LC_ID_DYLIB
      cmdsize 48
         name @rpath/libmqic_r.dylib (offset 24)
   time stamp 1 Thu Jan  1 01:00:01 1970
      current version 0.0.0
compatibility version 0.0.0
Load command 4
            cmd LC_DYLD_INFO_ONLY
        cmdsize 48
     rebase_off 0
    rebase_size 0
       bind_off 8192
      bind_size 40
  weak_bind_off 0
 weak_bind_size 0
  lazy_bind_off 0
 lazy_bind_size 0
     export_off 8232
    export_size 1008
Load command 5
     cmd LC_SYMTAB
 cmdsize 24
  symoff 9312
   nsyms 352
  stroff 14952
 strsize 1912
Load command 6
            cmd LC_DYSYMTAB
        cmdsize 80
      ilocalsym 0
      nlocalsym 281
     iextdefsym 281
     nextdefsym 68
      iundefsym 349
      nundefsym 3
         tocoff 0
           ntoc 0
      modtaboff 0
        nmodtab 0
   extrefsymoff 0
    nextrefsyms 0
 indirectsymoff 14944
  nindirectsyms 2
      extreloff 0
        nextrel 0
      locreloff 0
        nlocrel 0
Load command 7
     cmd LC_UUID
 cmdsize 24
    uuid EDA21FCE-4BC7-39FC-A150-95D20DE313A6
Load command 8
      cmd LC_VERSION_MIN_MACOSX
  cmdsize 16
  version 10.13
      sdk 10.13
Load command 9
      cmd LC_SOURCE_VERSION
  cmdsize 16
  version 0.0
Load command 10
          cmd LC_LOAD_DYLIB
      cmdsize 48
         name @rpath/libmqe_r.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 0.0.0
compatibility version 0.0.0
Load command 11
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libSystem.B.dylib (offset 24)
   time stamp 2 Thu Jan  1 01:00:02 1970
      current version 1252.50.4
compatibility version 1.0.0
Load command 12
      cmd LC_FUNCTION_STARTS
  cmdsize 16
  dataoff 9240
 datasize 72
Load command 13
      cmd LC_DATA_IN_CODE
  cmdsize 16
  dataoff 9312
 datasize 0
JoshMc
  • 10,239
  • 2
  • 19
  • 38
  • I've been testing out the new "IBM MQ macOS toolkit for developers" package and everything works so long as you do the shell environment variable (DYLD_LIBRARY_PATH) correctly. See here: https://www.capitalware.com/rl_blog/?p=5336 – Roger Mar 19 '19 at 19:49

2 Answers2

2

Python should know about /opt/mqm/lib64:

export PYTHONPATH=/opt/mqm/lib64

MacOS should know about /opt/mqm/lib64:

export DYLD_LIBRARY_PATH=/opt/mqm/lib64
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
0

IBM has released a set of dev patterns for MQ, and Python is included - https://github.com/ibm-messaging/mq-dev-patterns

My understanding is that most (I am guessing not the C#) have been tested on a mac, as they have mac set-up instructions - https://github.com/ibm-messaging/mq-dev-patterns/tree/master/Python

I suspect that you are missing -

Add /IBM-MQ-Toolkit-Mac-x64-9.1.1.0/bin and /IBM-MQ-Toolkit-Mac-x64-9.1.1.0/samp/bin, to the PATH by editing /etc/paths

export DYLD_LIBRARY_PATH = /IBM-MQ-Toolkit-Mac-x64-9.1.1.0/lib64

If this is the first time you have done any coding on your mac, you might be missing a c compiler. You will need to install Xcode.

chughts
  • 4,210
  • 2
  • 14
  • 27
  • Thanks for the quick respose... but I have these in path (just double checked): /opt/IBM/IBM-MQ-Toolkit-Mac-x64-9.1.1.0/bin /opt/IBM/IBM-MQ-Toolkit-Mac-x64-9.1.1.0/samp/bin. Also exported DYLD.. and LD... with two locations, both the real path and aliased via /opt/mqm – SQLGobbleDeGook Mar 19 '19 at 12:10
  • and `export DYLD_LIBRARY_PATH` ? – chughts Mar 19 '19 at 12:11
  • As you are new to development on Mac you might also need Xcode – chughts Mar 19 '19 at 12:12
  • Yep thats there too: /opt/mqm/lib64:/usr/local/lib:/opt/IBM/IBM-MQ-Toolkit-Mac-x64-9.1.1.0/lib64:/opt/mqm/lib:/opt/IBM/IBM-MQ-Toolkit-Mac-x64-9.1.1.0/lib – SQLGobbleDeGook Mar 19 '19 at 12:13
  • xcode is something you install once, per mac OS upgrade and forget about. – chughts Mar 19 '19 at 12:14
  • hang on, why do you have `/opt/mqm/lib` and `/opt/IBM/IBM-MQ-Toolkit-Mac-x64-9.1.1.0/lib64` and `/opt/IBM/IBM-MQ-Toolkit-Mac-x64-9.1.1.0/lib` in your `export DYLD_LIBRARY_PATH` ? You should only need `/opt/IBM/IBM-MQ-Toolkit-Mac-x64-9.1.1.0/lib64`. – chughts Mar 19 '19 at 14:09
  • Thats what it started with before I went down the road to try make it work :-) – SQLGobbleDeGook Mar 19 '19 at 16:28
  • In the question you say 'libmqic_r.dylib is available in two locations including /opt/mqm/lib64' What is the other location? Are they the same file? – chughts Mar 20 '19 at 13:22