Python and MQ

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vc1981
    New Member
    • Dec 2006
    • 1

    #1

    Python and MQ

    Hi ,

    I have a simple code as shown below :
    Code:
    import pymqi
    qmgr = pymqi.QueueManager()
    putQ = pymqi.Queue(qmgr, 'TESTQ1')
    putQ.put('Hello from Python!')
    When i run this piece of code i get an error as :

    File "C:\Python24\py mqi-0.5d\pymqi-0.5d\testmq.py" , line 1, in ?
    import pymqi
    File "C:\Python24\py mqi-0.5d\pymqi-0.5d\pymqi.py", line 82, in ?
    import pymqe, CMQC, CMQCFC
    ImportError: No module named pymqe


    Kindly advise !

    Thanks & Regards,
    VC
    Last edited by bartonc; Dec 12 '06, 09:05 AM. Reason: added code tags
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    This thread will be renamed to include the word "installati on" for future searches.

    Originally posted by vc1981
    Hi ,

    I have a simple code as shown below :
    Code:
    import pymqi
    qmgr = pymqi.QueueManager()
    putQ = pymqi.Queue(qmgr, 'TESTQ1')
    putQ.put('Hello from Python!')
    When i run this piece of code i get an error as :

    File "C:\Python24\py mqi-0.5d\pymqi-0.5d\testmq.py" , line 1, in ?
    import pymqi
    File "C:\Python24\py mqi-0.5d\pymqi-0.5d\pymqi.py", line 82, in ?
    import pymqe, CMQC, CMQCFC
    ImportError: No module named pymqe


    Kindly advise !

    Thanks & Regards,
    VC
    This sounds like some kind of installation problem. Python doesn't automatically search directories for modules. It does search all directories listed in sys.path. and the current working directory. There are several ways to add a directory to sys.path. If, for example, pymqe, CMQC, and CMQCFC are in C:\Python24\pym qi-0.5d\ instead of C:\Python24\pym qi-0.5d\pymqi-0.5d\, a simple trick that I use is: put these lines
    Code:
    import sys
    sys.path.append(r"C:\Python24\pymqi-0.5d")
    before
    import pymqi
    in your module.
    Some alternatives include:
    add or edit the environment varialbe PYTHONPATH to include the desired directory
    Move this package to C:\Python24\Lib \site-packages (a more proper place) and create a .pth file with the directory name in it.
    Actually the .pth file will probably work if you put it in C:\Python24\pym qi-0.5d\pymqi-0.5d\.
    Of course, none of this is any help if you simply don't have pymqe, CMQC, or CMQCFC modules/files.

    Comment

    Working...