Skip to content

Install & Run

Catherine Birney edited this page Sep 11, 2023 · 14 revisions

Prerequisites

  1. Python 3.9 or greater, 64-bit version - https://www.python.org/downloads/
  2. The latest version of pip. Included as a default option with Python installation.

Installation of python module

From command line, run:

pip install git+https://github.com/USEPA/flowsa#egg=flowsa

Or to install a specific version, run

pip install git+https://github.com/USEPA/[email protected]#egg=flowsa

where 'vX.X.X' is the version you wish to use under Releases.

You can test the installation by opening a Python console and entering

import flowsa

If no error is returned, the libraries are installed.

Example Code

Example code is found in the examples folder.

See model.earth for example code loading, subsetting, and saving Bureau of Labor Statistics County Industry Data.

Reading Parquet Files

FlowByActivity.py and FlowBySector.py generate parquet files. In python, use pandas to read the parquet file and save in another format.

Example to save as a csv:

import pandas
# load the parquet
df = pd.read_parquet(file_name)
# maintain leading 0s in location col
df.Location = df.Location.apply('="{}"'.format)
# save output to csv with a user defined output_path
df.to_csv(output_path + '_' + file_name + ".csv", index=False)


See this stackoverflow post for a discussion on GUI tools for viewing parquets.

FLOWSA Development in PyCharm

FLOWSA is developed using PyCharm on Windows, and instructions are provided for working with it in that environment.

Prerequisites for working from the latest code in master branch

  1. Python 3.7 or greater, 64-bit version
  2. PyCharm
  3. git
  4. The latest version of pip, included as a default option with Python installation.
  5. The packages specified in setup.py

Working with flowsa in PyCharm

  1. Fork the repository
  2. Open PyCharm, close all existing projects
  3. Select 'Check out from Version Control'.
  4. Copy and paste the git URL from the repository homepage for your forked repository into the 'URL' field. It is available by clicking on 'Clone' on that page and copying the URL. Putting in the URL should auto-populate the 'Directory' field. Click 'Clone'.
  5. Open the project. You will be warned if missing any dependencies. Install those and restart.
  6. Once back in, you should be able to open any .py file and run code line by line with Shift+Ctrl+E