Opened 5 years ago

Closed 16 months ago

#2608 closed defect (worksforme)

Launching Python script on Windows fails with missing freeze_support

Reported by: marisn Owned by: grass-dev@…
Priority: normal Milestone: 7.0.7
Component: Python Version: 7.0.0
Keywords: Cc:
CPU: Unspecified Platform: MSWindows Vista

Description

Launch the following script on Windows:

from grass.pygrass.modules.shortcuts import raster as r
r.mapcalc("rand0 = round(rand(0,1))", s=True)
r.neighbors(input="rand0", output="count", method="count")
r.mapcalc("rand1 = if (count > 3, 1, null())")
r.mapcalc("rand2 = if (count < 1, 1, null())")

and observe an error:

C:\Users\tests\Documents\rand.py                                                
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Program Files\GRASS GIS
7.0.0\Python27\lib\multiprocessing\forking.py", line 380, in
main
    prepare(preparation_data)
  File "C:\Program Files\GRASS GIS
7.0.0\Python27\lib\multiprocessing\forking.py", line 495, in
prepare
    '__parents_main__', file, path_name, etc
  File "C:\Users\tests\Documents\rand.py", line 2, in
<module>
    r.mapcalc("rand0 = round(rand(0,1))", s=True)
  File "C:\Program Files\GRASS GIS
7.0.0\etc\python\grass\pygrass\modules\interface\module.py",
line 616, in __call__
    return self.run()
  File "C:\Program Files\GRASS GIS
7.0.0\etc\python\grass\pygrass\modules\interface\module.py",
line 714, in run
    get_msgr().debug(1, self.get_bash())
  File "C:\Program Files\GRASS GIS
7.0.0\etc\python\grass\pygrass\messages\__init__.py", line
352, in get_msgr
    _instance[0] = Messenger(*args, **kwargs)
  File "C:\Program Files\GRASS GIS
7.0.0\etc\python\grass\pygrass\messages\__init__.py", line
175, in __init__
    self.start_server()
  File "C:\Program Files\GRASS GIS
7.0.0\etc\python\grass\pygrass\messages\__init__.py", line
185, in start_server
    self.server.start()
  File "C:\Program Files\GRASS GIS
7.0.0\Python27\lib\multiprocessing\process.py", line 130, in
start
    self._popen = Popen(self)
  File "C:\Program Files\GRASS GIS
7.0.0\Python27\lib\multiprocessing\forking.py", line 258, in
__init__
    cmd = get_command_line() + [rhandle]
  File "C:\Program Files\GRASS GIS
7.0.0\Python27\lib\multiprocessing\forking.py", line 358, in
get_command_line
    is not going to be frozen to produce a Windows executable.''')
RuntimeError:
            Attempt to start a new process before the current process
            has finished its bootstrapping phase.
            This probably means that you are on Windows and you have
            forgotten to use the proper idiom in the main module:
                if __name__ == '__main__':
                    freeze_support()
                    ...
            The "freeze_support()" line can be omitted if the program
            is not going to be frozen to produce a Windows executable.

Change History (9)

comment:1 Changed 5 years ago by martinl

Milestone: 7.0.1

comment:2 Changed 5 years ago by neteler

Milestone: 7.0.17.0.2

Ticket retargeted after 7.0.1 milestone closed

comment:3 Changed 5 years ago by neteler

Milestone: 7.0.27.0.3

Ticket retargeted after milestone closed

comment:4 Changed 5 years ago by neteler

Milestone: 7.0.3

Ticket retargeted after milestone closed

comment:5 Changed 5 years ago by neteler

Milestone: 7.0.4

Ticket retargeted after 7.0.3 milestone closed

comment:6 Changed 4 years ago by martinl

Milestone: 7.0.47.0.5

comment:7 Changed 4 years ago by neteler

Milestone: 7.0.57.0.6

comment:8 Changed 2 years ago by neteler

Milestone: 7.0.67.0.7

comment:9 Changed 16 months ago by martinl

Resolution: worksforme
Status: newclosed

Tested with GRASS 7.6.0 on Windows 8. Unable to reproduce.

Note: See TracTickets for help on using tickets.