Search code examples
pythoncanopy

Trying to run .py files in Enthought canopy in windows 8


I am trying to checkpoint in cell blender. In order to checkpoint I am running this py code in Canopy:

import random
from math import sqrt
import subprocess
import time

# Set clock
START=time.clock()

# Simulation Parameters - num_real_runs is needed to set the range command in python
num_runs=2

# Counter Variable for total numbers of runs
running=1

while (running<num_runs):   

    # Execute mcell Part1
    subprocess.call("mcell -seed "+str(running)+" change_dc1.mdl", shell=True)

    # Execute mcell Part2
    subprocess.call("mcell -seed "+str(running)+" change_dc2.mdl", shell=True)

    # Calculate elapsed time for executing python script only (in min)
    END=time.clock()
    ELAPSED=(END-START)
    print "Man, it took me only", ELAPSED, "seconds to run the python code!"    
    running+=1

But for some reason it isn't creating a file saying the program ran. Any suggestions?


Solution

  • Because Canopy Python is the Jupyter / IPython QtConsole, which is already running 2 processes (front-end in the GUI, kernel in the background), it can get tricky to try to figure what's happening with a program like yours which is launching additional processes. I would recommend running it, at least initially, in a simpler environment. From the Canopy Tools menu, open a Canopy Command Prompt, start a single-process ipython terminal by typing ipython, then from the ipython prompt (In[1]), cd to the desired directory and type %run myfile.py.