Setup for OpenPath - bellevuewa/BKRCast GitHub Wiki

System Setup

IF you are using EMME 4.7, please follow instructions on this page. Instructions on this page are only applicable to Bentley OpenPath EMME24.0 or above.

Step 1: Install Bentley OpenPath EMME24.01 64-bit

Step 2: Install Anaconda 3

  • Download Anaconda 3 from Anaconda3-2024.10-1-Windows-x86_64.
  • Install Anaconda 3. Use all default settings except the installation location. Anaconda should be installed directly under C:\Users\[user_name]. image

Step 3: create a virtual environment named BKRCast

Exercise patience during these steps.

a. Create virtual environment named BKRCast
conda create --name BKRCast python=3.11.7
conda activate BKRCast

The BKRCast virtual environment folder is located in [anaconda_installation_folder]\envs\BKRCast.

b. Install numpy 1.26.2
conda install numpy=1.26.2

c. Install pandas 2.0.2
conda install pandas=2.0.2 -c conda-forge

d. Install geopandas using pip.
pip install geopandas
The current geopandas is 1.0.1. Installation through conda does not work well with the conda virtual environment and EMME packages.

e. Install pandana
conda install pandana -c conda-forge

f. Install h5py
conda install h5py -c conda-forge

g. Install toml
conda install toml -c conda-forge

h. Install xlsxwriter
conda install xlsxwriter -c conda-forge

i. Install openpyxl
conda install openpyxl -c conda-forge

j. Install jenkspy
conda install jenkspy -c conda-forge

The packages to be installed below are only used when calculating cumulative slopes.
k. Install rasterio pip install rasterio
The tested version is 1.4.3.

l. Install rasterstats pip install rasterstats
The tested version is 0.20.0.

m. Install PyQt6
conda install pyqt
The tested version is PyQt6 6.7.1.

Step 4: Activate the virtual environment by using this command line:

conda activate BKRCast
If you want to exit the BKRCast virtual environment, run the command line:
conda deactivate

Step 5: Change python path in EMME to the BKRCast virtual environment

  • Open EMME Desktop
  • Go to Tools → Application Options → Modeller Setup EMME
  • Change Python Path to the BKRCast environment folder that was created in Step 3. For example, C:\Users\hdong\Anaconda3\envs\BKRCast.
  • Select Install Package or Update Modeller Package and click OK.
  • Go to BKRCast virutal environment BKRCast\Lib\site-packages. Verify emme.pth file has been copied to this location. Otherwise, manually copy this file [Emme Path]\emme.pth to env\BKRCast\Lib\site-packages.
  • Close Emme.

Step 6: Change Windows system path environment variable

Right click the Start icon and select Settings. In the right column, click on Advanced system settings, followed by Environment Variables. Double click on Path under System variables section. Incorporate the following paths into the path variable.
C:\Users\hdong\Anaconda3\envs\BKRCast\Library\bin

system_variable path_variable

Step 7: Create PYTHONPATH system variable.

Set paths (similar as below) to PYTHONPATH. Your paths will be different.
%EMMEPATH%\programs;%EMMEPATH%\Python311\modeller;C:\Users\hdong\Anaconda3\envs\BKRCast\Library\bin;C:\Users\hdong\Anaconda3\envs\BKRCast;C:\Users\hdong\Anaconda3\envs\BKRCast\Library\mingw-w64\bin;C:\Users\hdong\Anaconda3\envs\BKRCast\Library\usr\bin;C:\Users\hdong\Anaconda3\envs\BKRCast\Scripts;C:\Users\hdong\Anaconda3\envs\BKRCast\bin;C:\Users\hdong\Anaconda3\condabin PYTHONPATH

Step 8: Test

Open anaconda powershell prompt window. Run the following command lines.
Attention: Anaconda may automatically create a shortcut to the BKRCast virtual environment. Do not use it. It may or may not work. Always start from Anaconda prompt window.
conda activate BKRCast
cd d:\
python
import inro.emme.desktop.app
import inro.modeller
import geopandas
import fiona
If no error message appears, the Emme packages have been successfully installed in anaconda.

Errors Related to "module os has no attribute 'add_dll_directory'"
You might encounter an error similar to the following:
image The error is most likely caused by incompatibility with fiona. The compatible version is 1.9.4. To verify, run the following command in BKRCast virtual environment.
conda list fiona

If fiona is version 1.9.5 or newer, it confirms the incompatibility. To resolve this issue, follow these steps:
pip uninstall fiona
pip install fiona==1.9.4

If you see messages like the ones in this screenshot, it means fiona 1.9.4 is already installed somewhere (likely as part of EMME installation). In this case, you can skip the fiona installation step. image

Now you can test it in BKRCast virtual environment again.
python import fiona

Errors Related to 'Some dll is not loaded'
If you encounter an error message saying some dll is not loaded, first make sure the environmental variables are configured correctly (e.g., %EMMEPATH%\programs;%EMMEPATH%\Python311\modeller are included in PYTHONPATH, not in PATH). If the error still exists, try this additional step below:

  • Create a text file named set_path_for_BKRCast.bat in the root directory of D drive.
  • Add the following two lines to this batch file.
    set EMMEPATH=C:\Program Files\Bentley\OpenPaths\EMME 24.00.00
    set PATH=%EMMEPATH%\programs;%EMMEPATH%\Python311\modeller;%PATH%

This batch file ensures that Python package search commence from EMME installation, preventing potential issues where certain packages might remain undiscovered, leading to unexpected errors.

Attempt to launch EMME modeler. If it opens smoothly without any complications, you have successfully configured teh Ananconda BKRCast environmnet.

Optional software tools

Git

Download Git from https://git-scm.com/download/win. Choose latest 64-bit Windows version. Follow the installation instructions to complete installation.

Git Credential Manager

It is recommended to download and install git credential manager for Windows.

TortoiseGit

Download TortoiseGit from https://tortoisegit.org/download/. Choose latest 64-bit version. Follow the installation instruction to complete installation.

Notepad++

Notepad++ is a powerful open source text editor. here is the download link.

Model Setup

The following steps are recommended to set up the BKRCast model on a machine:

  1. Download setup:
  • Open command prompt window (console mode). Change current directory to the working directory.
  • Run command git clone https://github.com/bellevuewa/BKRCast. This command is to clone the BKRCast repository. This is a public repository and primarily contains scripts/programs and configuration files.
    Daysim is installed in daysim_2019 subfolder. The current Daysim version BKRCast is using is 2.2.0-beta.427.
  • Get the BKRCast input files. Save input files under BKRCast/inputs. We no longer keep BKRCastInputs on GitHub.
  1. Update input_configuration.py:
  • Under BKRCast root folder, open input_configuration.py in a text editor.
  • Set project_folder to the BKRCast folder on the target machine
  • Set parcels_file_folder to the directory of the primary parcel file

Update input_configuration.py

The following tree diagram represents a BKRCast model directory that is ready for a model run based on the aforementioned setup guidance.

BKRCast Model Directory