Issue Building from Source and Using Pip

Hello Open Water Analytics Community,

After playing around with the official EPANet and its python bindings, I’m looking to try out OWA-EPANet but I’ve run into some issues.

I first attempted to install owa-epanet with pip which seemed to go off without a hitch.

However, I try to run import epanet.toolkit as en I get the following error.

Python 3.7.6 (default, Jan  8 2020, 19:59:22)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import epanet.toolkit as en
Traceback (most recent call last):
  File "/home/max/miniconda3/lib/python3.7/site-packages/epanet/toolkit.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "/home/max/miniconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 583, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1043, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/max/miniconda3/lib/python3.7/site-packages/epanet/toolkit.py", line 17, in <module>
    _toolkit = swig_import_helper()
  File "/home/max/miniconda3/lib/python3.7/site-packages/epanet/toolkit.py", line 16, in swig_import_helper
    return importlib.import_module('_toolkit')
  File "/home/max/miniconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_toolkit'

Next, I tried building from source, but I ran into a similar issue when I got to the build testing step.

ImportError while importing test module '/mnt/c/Users/maxwe/OneDrive/Documents/UpWork/Water/OWA/epanet-python/owa-epanet/test/test_owa_epanet.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/max/.local/share/virtualenvs/test-zsKarjrw/lib/python3.7/site-packages/epanet/toolkit.py:14: in swig_import_helper
    return importlib.import_module(mname)
/home/max/miniconda3/lib/python3.7/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1006: in _gcd_import
    ???
<frozen importlib._bootstrap>:983: in _find_and_load
    ???
<frozen importlib._bootstrap>:967: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:670: in _load_unlocked
    ???
<frozen importlib._bootstrap>:583: in module_from_spec
    ???
<frozen importlib._bootstrap_external>:1043: in create_module
    ???
<frozen importlib._bootstrap>:219: in _call_with_frames_removed
    ???
E   ImportError: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:
test_owa_epanet.py:5: in <module>
    import epanet.toolkit as en
/home/max/.local/share/virtualenvs/test-zsKarjrw/lib/python3.7/site-packages/epanet/toolkit.py:17: in <module>
    _toolkit = swig_import_helper()
/home/max/.local/share/virtualenvs/test-zsKarjrw/lib/python3.7/site-packages/epanet/toolkit.py:16: in swig_import_helper
    return importlib.import_module('_toolkit')
/home/max/miniconda3/lib/python3.7/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
E   ModuleNotFoundError: No module named '_toolkit'

I successfully compiled OWA-EPANet without the python bindings and I was able to use it via CLI but I’d really like to be able to use the python bindings. I’m working in an Ubuntu 18.04 environment. Does anyone have any advice or guidance on what I’m doing wrong?

I was able to resolve the problem by downloading the shared python runtime library which I was missing.

sudo apt-get install libpython3.7

I also asked this question here.