Problem with Python/Golly

For scripts to aid with computation or simulation in cellular automata.
Post Reply
User avatar
Wojowu
Posts: 210
Joined: October 1st, 2011, 1:24 pm

Problem with Python/Golly

Post by Wojowu » October 9th, 2011, 2:59 pm

I've installed Python 2.7.2 from website which is in Golly help. When I click any pattern with .py message shows:
If Python isn't installed then you will have to Cancel, otherwise change the version number to match the version installed on your system and try again.
If it fails, search your system for a python*.dll file and enter the full path to that file.
But there is a problem: In downloaded package there is no .dll file with "python" in its name. I used Python 2.7.2 Windows Installer.
First question ever. Often referred to as The Question. When this question is asked in right place in right time, no one can lie. No one can abstain. But when The Question is asked, silence will fall. Silence must fall. The Question is: Doctor Who?

User avatar
12Glider
Posts: 79
Joined: December 17th, 2010, 4:56 pm

Re: Problem with Python/Golly

Post by 12Glider » October 9th, 2011, 4:32 pm

Did you enter the full path to the file? If not, check in the Python27 Folder.
Image

Why hasn't a glider exploded yet?

User avatar
Andrew
Moderator
Posts: 942
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: Problem with Python/Golly

Post by Andrew » October 9th, 2011, 6:15 pm

On my Windows XP system python27.dll is in C:\WINDOWS\system32. If the dll is not in that location on your system then I'm guessing you're using a newer version of Windows (7?) and the Python installer puts the dll in a different location. Use Windows Explorer to do an advanced search for python*.dll and search all files and folders in your C disk, including hidden files. Please let us know where you find it so we can tell other people who have the same problem.
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

User avatar
Wojowu
Posts: 210
Joined: October 1st, 2011, 1:24 pm

Re: Problem with Python/Golly

Post by Wojowu » October 10th, 2011, 2:37 pm

I have folder Python27 in C: but I still don't know where is python*.dll file! I searched C: and whole computer and I found 3 python*.dll files: 2 for MCEdit (Minecraft editor) and 1 for Metin, none in C:
I have Windows 7, and I have polish version (I am from Poland) and I don't know where is Windows Explorer
First question ever. Often referred to as The Question. When this question is asked in right place in right time, no one can lie. No one can abstain. But when The Question is asked, silence will fall. Silence must fall. The Question is: Doctor Who?

User avatar
Andrew
Moderator
Posts: 942
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: Problem with Python/Golly

Post by Andrew » October 10th, 2011, 6:18 pm

I have folder Python27 in C: but I still don't know where is python*.dll file! ...
First thing: did you download the 32-bit version of Python? Golly is a 32-bit app so it won't work with a 64-bit Python.

After some googling it appears that in Windows 7 python27.dll should be located in C:\Windows\SysWOW64, so when you get Golly's error dialog after trying to run a .py script, try entering this string:

Code: Select all

C:\Windows\SysWOW64\python27.dll
Let us know if that works.
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

User avatar
Wojowu
Posts: 210
Joined: October 1st, 2011, 1:24 pm

Re: Problem with Python/Golly

Post by Wojowu » October 11th, 2011, 9:05 am

I just entered your (Andrew) string and it now works!!!
Thanks for help

Edit:
I don't want to make new topic when old is still on top, so I say that here
Something is wrong with save-image.py on http://www.conwaylife.com/scripts/
When i try it long error message appears
First question ever. Often referred to as The Question. When this question is asked in right place in right time, no one can lie. No one can abstain. But when The Question is asked, silence will fall. Silence must fall. The Question is: Doctor Who?

User avatar
Andrew
Moderator
Posts: 942
Joined: June 2nd, 2009, 2:08 am
Location: Melbourne, Australia
Contact:

Re: Problem with Python/Golly

Post by Andrew » October 23rd, 2011, 8:19 pm

I'm guessing the error message says you need to install PIL (the Python Imaging Library). If you don't want to do that then below is a script that saves the current pattern/selection as a .bmp file:

Code: Select all

# Use glife's WriteBMP routine to save the current selection or pattern
# in a user-specified .bmp file.  Requires Golly 2.2 or later.
# Author: Andrew Trevorrow (andrew@trevorrow.com), Oct 2011.

import golly as g
from glife.WriteBMP import WriteBMP
import os.path

if g.empty(): g.exit("There is no pattern.")

prect = g.getrect()
srect = g.getselrect()
if len(srect) > 0: prect = srect    # save selection rather than pattern
x = prect[0]
y = prect[1]
wd = prect[2]
ht = prect[3]

# prevent Python allocating a huge amount of memory
if wd * ht >= 100000000:
   g.exit("Bitmap area is restricted to < 100 million cells.")

multistate = g.numstates() > 2
colors = g.getcolors()     # [0,r0,g0,b0, ... N,rN,gN,bN]
state0 = (colors[1],colors[2],colors[3])

# create 2D array of pixels filled initially with state 0 color
pixels = [[state0 for col in xrange(wd)] for row in xrange(ht)]

g.show("Creating bitmap image...")
cellcount = 0
for row in xrange(ht):
   # get a row of cells at a time to minimize use of Python memory
   cells = g.getcells( [ x, y + row, wd, 1 ] )
   clen = len(cells)
   if clen > 0:
      inc = 2
      if multistate:
         # cells is multi-state list (clen is odd)
         inc = 3
         if clen % 3 > 0: clen -= 1    # ignore last 0
      for i in xrange(0, clen, inc):
         if multistate:
            n = cells[i+2] * 4 + 1
            pixels[row][cells[i]-x] = (colors[n],colors[n+1],colors[n+2])
         else:
            pixels[row][cells[i]-x] = (colors[5],colors[6],colors[7])
         cellcount += 1
         if cellcount % 1000 == 0:
            # allow user to abort huge pattern/selection
            g.dokey( g.getkey() )

if cellcount == 0: g.exit("Selection is empty.")
g.show("")

# set initial directory for the save dialog
initdir = ""
savename = g.getdir("data") + "save-as-bmp.ini"
try:
   # try to get the directory saved by an earlier run
   f = open(savename, 'r')
   initdir = f.readline()
   f.close()
except:
   # this should only happen the very 1st time
   initdir = g.getdir("data")

# remove any existing extension from layer name and append .bmp
initfile = g.getname().split('.')[0] + ".bmp"

# prompt user for output file
outfile = g.savedialog("Save as BMP file", "BMP (*.bmp)|*.bmp",
                       initdir, initfile)
if len(outfile) > 0:
   g.show("Writing .bmp file...")
   WriteBMP(pixels, outfile)
   g.show("File created: " + outfile)
   
   # remember file's directory for next time
   try:
      f = open(savename, 'w')
      f.write(os.path.dirname(outfile))
      f.close()
   except:
      g.warn("Unable to save directory to file:\n" + savename)
Use Glu to explore CA rules on non-periodic tilings: DominoLife and HatLife

Post Reply