# Running ROOT under Linux / as CLI or Python module

**URL:** <https://community.naturalcapitalalliance.org/t/running-root-under-linux-as-cli-or-python-module/1898>\
**Category:** Software Support\
**Tags:** python, root\
**Created:** [May 8, 2021, 11:54am UTC](https://community.naturalcapitalalliance.org/t/running-root-under-linux-as-cli-or-python-module/1898 "2021-05-08T11:54:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![olessko](https://avatars.discourse-cdn.com/v4/letter/o/c0e974/32.png) [@olessko](https://community.naturalcapitalalliance.org/u/olessko)\
**Post date:** [May 8, 2021, 11:54am UTC](https://community.naturalcapitalalliance.org/t/running-root-under-linux-as-cli-or-python-module/1898/1 "2021-05-08T11:54:28Z")

</div>

I am exploring a way to run the Restoration Opportunities Optimization Tool under Debian Linux as a command line tool or as a Python library , and somehow I am having difficulties setting up all dependencies. I took the application from [ROOT | Natural Capital Project](https://naturalcapitalproject.stanford.edu/software/root) , unpacked it using pyextractor and uncompiled it using uncompyle6 so that I could get the source .py files , but was not able to run python “root\_parameters.py” due to various errors (the last one being StopIteration in preprocessing.py). Windows packaged exe file runs OK though.

I wonder whether it would be possible to get Python code for ROOT as well as system configuration / dependencies information. I would highly appreciate any other hints and ideas on how to run ROOT as a command line tool or Python module under Linux.

Thank you very much in advance for your response.

---

<div class="post-metadata">

**Author:** ![olessko](https://avatars.discourse-cdn.com/v4/letter/o/c0e974/32.png) [@olessko](https://community.naturalcapitalalliance.org/u/olessko)\
**Post date:** [May 8, 2021, 1:14pm UTC](https://community.naturalcapitalalliance.org/t/running-root-under-linux-as-cli-or-python-module/1898/2 "2021-05-08T13:14:12Z")

</div>

To add more details: apparently there is a problem with marginal\_tables/marginals.csv file generation: under Windows it is a larger file with a lot of columns, while under Linux when I rtry to run Root with the same input files and parameters it only contains a partial header, and no values:

SDU\_ID,pixel\_count,area\_ha,maskpixct,maskpixha

---

<div class="post-metadata">

**Author:** ![jdouglass](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/jdouglass/32/9_2.png) [@jdouglass](https://community.naturalcapitalalliance.org/u/jdouglass)\
**Post date:** [May 10, 2021, 4:33pm UTC](https://community.naturalcapitalalliance.org/t/running-root-under-linux-as-cli-or-python-module/1898/3 "2021-05-10T16:33:27Z")

</div>

Hi @olessko , that’s neat that you went through all the trouble of decompiling the binaries! It’ll be way easier for you to just clone and run the [source code from the root repository](https://github.com/natcap/root), though 🙂

The thing about package versions is that the `debian:stable` repos are typically pretty far behind the latest package versions, so the easiest way to get a functional environment up and running would be to use `conda`. I use `miniconda` myself ([download page](https://docs.conda.io/en/latest/miniconda.html)).

Assuming you have miniconda all set up and on your `PATH`, here’s what you’ll want to do to get a local version of ROOT up and running:

```auto
sudo apt-get install build-essential
git clone https://github.com/natcap/root.git
cd root
conda env create -p ./root-env -f environment.yml
conda activate ./root-env
python setup.py install
python natcap/root/root.py

```

Let us know how this goes!  
James

---

<div class="post-metadata">

**Author:** ![olessko](https://avatars.discourse-cdn.com/v4/letter/o/c0e974/32.png) [@olessko](https://community.naturalcapitalalliance.org/u/olessko)\
**Post date:** [May 11, 2021, 2:34pm UTC](https://community.naturalcapitalalliance.org/t/running-root-under-linux-as-cli-or-python-module/1898/4 "2021-05-11T14:34:21Z")

</div>

Hi James,

Thank you very much for the advice and for the link to git repository. Somehow I could not find it, and thought that decompiling ROOT would be the only option 🙂

Anaconda-based install worked reasonably well (had to install GDAL and natcap.invest manually before that), but I am still not able to run ROOT properly, as a Python command line tool without GUI. I removed natcap.gui sections and try to call ROOT with python root\_parameters.py script that works fine with an older ROOT version, but  
a) ROOT does not generate output/sdu\_value\_tables/baseline.csv table but fails:  
` File "/home/admin/root/natcap/root/root.py", line 535, in validate_objectives_and_constraints_tables with open(baseline_sdu_stats_file) as f: FileNotFoundError: [Errno 2] No such file or directory: '/home/admin/data/output/sdu_value_tables/baseline.csv'`

b) when I copy the baseline.csv table from a successful ROOT GUI run under Windows I get an error message  
` File "/home/admin/root/natcap/root/root.py", line 552, invalidate_objectives_and_constraints_tables raise RootInputError(msg) root.RootInputError: Error in Objectives table. The following factors were not found in the sdu value tables: ['weight', 'objective', 'minmax']`

It looks like the headers structure in the config csv files were changed between ROOT versions, and I have a functioning project that works fine with an older ROOT version under Windows.

Would you be able to share a functioning set of input files and parameters so that I could identify and fix the differences between an older ROOT version and the one from the repository?

Thanks a lot in advance!

Oles

---

<div class="post-metadata">

**Author:** ![bouthayna](https://avatars.discourse-cdn.com/v4/letter/b/dfb087/32.png) [@bouthayna](https://community.naturalcapitalalliance.org/u/bouthayna)\
**Post date:** [March 16, 2022, 1:48pm UTC](https://community.naturalcapitalalliance.org/t/running-root-under-linux-as-cli-or-python-module/1898/5 "2022-03-16T13:48:14Z")

</div>

Would you be able to share a functioning set of input files and parameters so that I could identify and fix the differences between an older ROOT version and the one from the repository?  
i’m i nteressting too

---

<div class="post-metadata">

**Author:** ![esoth](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@esoth](https://community.naturalcapitalalliance.org/u/esoth)\
**Post date:** [March 17, 2022, 12:29am UTC](https://community.naturalcapitalalliance.org/t/running-root-under-linux-as-cli-or-python-module/1898/6 "2022-03-17T00:29:58Z")

</div>

Let’s keep this discussion on [this thread](https://community.naturalcapitalalliance.org/t/how-to-produce-roots-inputs/2598).

---

<div class="post-metadata">

**Author:** ![jdouglass](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.naturalcapitalalliance.org/jdouglass/32/9_2.png) [@jdouglass](https://community.naturalcapitalalliance.org/u/jdouglass)\
**Post date:** [March 21, 2022, 6:38pm UTC](https://community.naturalcapitalalliance.org/t/running-root-under-linux-as-cli-or-python-module/1898/7 "2022-03-21T18:38:14Z")

</div>

Closed on March 21, 2022, 6:38pm UTC


