Quesion about running a exe file in Python(Not enough memory)

Discussion in 'Python' started by yuyaxuan0@gmail.com, Apr 25, 2013.

  1. Guest

    Hey guys,

    I have a python script that will call an external exe file. Code is kind of like this:

    import sys
    import os
    from helper_functions import strContains

    if (len(sys.argv) != 4):
    print('Usage of script: export_mirax_data <pathToSourceMiraxData> <pathToResultData> <tileSize>')
    else:
    print('Script to export mirax data')
    print('---------------------------')

    # default parameters for exporting
    zoomLevel = 0 # 0 (original) - 9 (whole slide on one image)
    tileHeight = 2048 # has to be a multiple of 256
    tileWidth = 2048 # has to be a multiple of 256
    fileFormat = "png" # jpg, png and bmp are allowed
    mapFileFormat = "png" # xml, png and bmp are allowed

    # implicitly needed parameters
    MiraxSlideExporter = "MrxSlideExport.exe"

    slicePath = sys.argv[1]
    pathToResultData = sys.argv[2]
    tileHeight = sys.argv[3]
    tileWidth = sys.argv[3]

    # slices = os.listdir(pathToSourceMiraxData)

    # sys.argv[1]
    # sys.argv[2]

    # create command-line for system-call of mirax-slide-exporter
    # -e exports the slide
    # -i saves slide information in outputfolder
    # -a optional
    # -n only tiles which contain information are exported
    # -s + pathToSourceMiraxData + \
    cmdForExportingSlicesToTiles = \
    MiraxSlideExporter + \
    " -i " + \
    " -e " + \
    " -z " + str(zoomLevel) + \
    " -t " + str(tileHeight) + " " + str(tileWidth) + \
    " -f " + str(fileFormat) + \
    " -m " + str(mapFileFormat) + \
    " "

    #cmd = "D:\\programs\\MIRAX_SlideAC_SDK\\Bin\\MrxSlideExport.exe -s D:\\fit\\projects\\bayer\\KidneyLiver\\MiraxScanner\\Slides\\L10 -e -o D:\\fit\\projects\\bayer\\KidneyLiver\\MiraxScanner\\Output\\L10 -z 5 -f png"
    #os.system(cmd)
    #msg = os.popen(cmd, mode='r', buffering=-1) # does not work
    #print(msg)

    # run through slices in given source-path


    cmd = cmdForExportingSlicesToTiles + " -s " + slicePath + " -o " + pathToResultData
    print(cmd)
    os.system(cmd)



    So the problem is that is says it doesn't have sufficient memory.

    The weired thing is that if I just ran the exe file directly in cmd console, it's working without any memory problem. I am wondering whether if it's some kind of python issue limits the memory that we can use??
     
    , Apr 25, 2013
    #1
    1. Advertising

  2. Dave Angel Guest

    On 04/25/2013 05:18 PM, wrote:
    > Hey guys,
    >
    > I have a python script that will call an external exe file. Code is kind of like this:
    >


    This is a perfect example where you can simplify the problem down to a
    few lines that fail for you, and actually document the environment and
    the results.



    > #cmd = "D:\\programs\\MIRAX_SlideAC_SDK\\Bin\\MrxSlideExport.exe -s D:\\fit\\projects\\bayer\\KidneyLiver\\MiraxScanner\\Slides\\L10 -e -o D:\\fit\\projects\\bayer\\KidneyLiver\\MiraxScanner\\Output\\L10 -z 5 -f png"
    > #os.system(cmd)
    > #msg = os.popen(cmd, mode='r', buffering=-1) # does not work


    That's a useless statement. What you really should be saying is: I ran
    exactly xxx, and it formatted my neighbor's D: drive. Or you should
    skip that, and just concentrate on the ancient os.system() you're asking
    about. BTW, any reason you're not using the multiprocess module? It
    can simplify a lot of things, for example, bypassing the shell, so you
    know what the child program is really getting as parameters.

    > cmd = cmdForExportingSlicesToTiles + " -s " + slicePath + " -o " + pathToResultData
    > print(cmd)
    > os.system(cmd)
    >
    > So the problem is that is says it doesn't have sufficient memory.


    Who says? At what point do they say it? Show us a transcript of
    exactly what you do to see this message, and actually show the message.


    You probably could simplify this to 5 lines:

    import os
    cmd = "some literal string with lots of options"
    print "About to launch program"
    print cmd
    os.system(cmd)

    Then you run it from the cmd line, and copy/paste the results into your
    mnext message.

    C:\Somedir\ > python myprog.py
    About to launch program
    some literal...

    Some message that might mention running out of memory...

    Naturally, you should specify your Python version, your OS version, and
    any other variables you can think of.

    --
    DaveA
     
    Dave Angel, Apr 25, 2013
    #2
    1. Advertising

  3. On Thu, 25 Apr 2013 14:18:58 -0700, yuyaxuan0 wrote:

    > Hey guys,
    >
    > I have a python script that will call an external exe file. Code is kind
    > of like this:


    "Kind of like"? So it might be different? How much different?

    [snip irrelevant code]

    Please try to cut your code down to the minimum necessary to demonstrate
    the problem.


    > #cmd = "D:\\programs\\MIRAX_SlideAC_SDK\\Bin\\MrxSlideExport.exe -s
    > D:\\fit\\projects\\bayer\\KidneyLiver\\MiraxScanner\\Slides\\L10 -e
    > -o D:\\fit\\projects\\bayer\\KidneyLiver\\MiraxScanner\\Output\\L10
    > -z 5 -f png"


    You can simplify Windows pathnames by using forward slashes.


    > #os.system(cmd)
    > #msg = os.popen(cmd, mode='r', buffering=-1) # does not work
    > #print(msg)


    Of course it does not work. You have commented it out.


    > # run through slices in given source-path
    > cmd = cmdForExportingSlicesToTiles + " -s " + slicePath + " -o " +
    > pathToResultData
    > print(cmd)
    > os.system(cmd)
    >
    > So the problem is that is says it doesn't have sufficient memory.


    What says "it" doesn't have sufficient memory? What's "it"? You may have
    seen the error, but we haven't. Please COPY AND PASTE the exact error
    message, IN FULL, and describe where it comes from:

    * is it a Python traceback?

    * something printed directly to the terminal but not a traceback?

    * Blue Screen of Death?

    * a message in a GUI alert?

    * something else?



    > The weired thing is that if I just ran the exe file directly in cmd
    > console, it's working without any memory problem. I am wondering whether
    > if it's some kind of python issue limits the memory that we can use??


    No.



    --
    Steven
     
    Steven D'Aprano, Apr 25, 2013
    #3
  4. Guest

    OK...

    1."Memory is not enough..." is giving from the exe program.
    2. If I run the exe program directly using cmd console, it's working good.
    3. I am using Windows 7, 4GB memory python 2.7 the program is a image processing program.
     
    , Apr 25, 2013
    #4
  5. rusi Guest

    On Apr 26, 3:11 am, wrote:
    > OK...
    >
    > 1."Memory is not enough..." is giving from the exe program.
    > 2. If I run the exe program directly using cmd console, it's working good..
    > 3. I am using Windows 7, 4GB memory python 2.7 the program is a image processing program.


    It may be good to go thruogh http://sscce.org/
    Your earlier data was too long
    Now its not self-contained (and not an example)
     
    rusi, Apr 26, 2013
    #5
  6. On Fri, Apr 26, 2013 at 8:00 AM, Steven D'Aprano
    <> wrote:
    > On Thu, 25 Apr 2013 14:18:58 -0700, yuyaxuan0 wrote:
    >> #cmd = "D:\\programs\\MIRAX_SlideAC_SDK\\Bin\\MrxSlideExport.exe -s
    >> D:\\fit\\projects\\bayer\\KidneyLiver\\MiraxScanner\\Slides\\L10 -e
    >> -o D:\\fit\\projects\\bayer\\KidneyLiver\\MiraxScanner\\Output\\L10
    >> -z 5 -f png"

    >
    > You can simplify Windows pathnames by using forward slashes.


    These paths are being given to an external tool, so I wouldn't
    guarantee that forward slashes will work. But you can use a raw string
    literal to avoid doubling them all up.

    ChrisA
     
    Chris Angelico, Apr 26, 2013
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SFoley

    ASP.NET not using enough memory?

    SFoley, Jul 24, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    447
    Craig Scurlock
    Jul 29, 2003
  2. =?Utf-8?B?RGVlcmFq?=

    Not enough memory for operation

    =?Utf-8?B?RGVlcmFq?=, Jul 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    3,926
    =?Utf-8?B?RGVlcmFq?=
    Jul 11, 2005
  3. tony lincoln

    excel---HSSF---not enough memory?

    tony lincoln, Mar 1, 2004, in forum: Java
    Replies:
    0
    Views:
    922
    tony lincoln
    Mar 1, 2004
  4. Chaos
    Replies:
    1
    Views:
    419
  5. Is my memory is not enough?

    , Jan 30, 2005, in forum: C Programming
    Replies:
    10
    Views:
    457
    Peter Shaggy Haywood
    Jan 31, 2005
Loading...

Share This Page