Running a Python ABM

Running a Python ABM

These instructions are for Mac OS X. A similar process probably applies for Windows; you may have luck with Spyder.

  1. The agent-based models (ABMs) here are written in Python 3. Your system likely has Python 2 pre-installed. Download and install the latest version of Python 3.
  2. Download and install TextMate
  3. Go to the “Variables” tab in Textmate’s preferences
  4. Add a new variable. Name it TM_PYTHON and set the value to /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
  5. Open the .py file in Textmate and press Command-R – Python should launch, and the model should run.
    • Pressing Command-Shift-R instead will bring up a Terminal window and give you command-line access to the model’s variables as it runs.
  6. If you get an error to the effect of ImportError: "No module named 'something'":
    • Install PIP
    • Open the terminal and type pip install something where ‘something’ is the name of the missing module. (If this doesn’t work, try python3 -m pip install something)
    • Repeat the previous step until the model runs


About »

Hi, I'm C. Harwick, an economist in New York State with an interest in monetary theory, institutional evolution, and folk music.

Care to know more? Read on »

Twitter »

    • Sep2413:17
      BTC at 6,666.6666 repeating, up 0.6666% (repeating, of course). 🤔
    • Sep2411:54
      I’ve now been able to work in both Napoleon Bonaparte and Napoleon Dynamite into my Principles of Macro lectures.

      Left: Bonaparte on how England avoided the resource curse
      Right: Dynamite on why the Labor Theory of Value is wrong

Design By Cameron Harwick Powered By Wordpress Hosted By Nearlyfreespeech No Copyrights