Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: name 'sys' is not defined #25

Open
rarygit opened this issue Feb 18, 2022 · 2 comments
Open

NameError: name 'sys' is not defined #25

rarygit opened this issue Feb 18, 2022 · 2 comments

Comments

@rarygit
Copy link

rarygit commented Feb 18, 2022

OS: Ubuntu 20.04
pip3 venv = py3swmm
python=v3.9
Is there an issue using python v3.9, rather than v3.8.3?

Trying to run ostrich-swmm for the first time, so any help appreciated.

I built and installed ostrich-swmm "lsmatott" in pip3 venv (the conda setup had too many conflicts) .
I am following the tutorial documentation, using the *.inp file to run this test.
I received the NameError: name 'sys' is not defined
I checked the listed files at their respective lines, but could not find a solution

Attached are the input and config files and the swmm5 executable.
Thanks for any help in getting this to run.

test_ostrich-swmm.zip

sh ostrich-swmm.sh
Traceback (most recent call last):
File "/media/l1nux/SAN240/py3venv/py3swmm/bin/ostrich-swmm", line 33, in
sys.exit(load_entry_point('ostrich-swmm==0.6.0', 'console_scripts', 'ostrich-swmm')())
File "/media/l1nux/SAN240/py3venv/py3swmm/lib/python3.9/site-packages/ostrich_swmm-0.6.0-py3.9.egg/ostrich_swmm/main.py", line 247, in main
File "/media/l1nux/SAN240/py3venv/py3swmm/lib/python3.9/site-packages/ostrich_swmm-0.6.0-py3.9.egg/ostrich_swmm/main.py", line 116, in run_cmd
File "/media/l1nux/SAN240/py3venv/py3swmm/lib/python3.9/site-packages/ostrich_swmm-0.6.0-py3.9.egg/ostrich_swmm/run.py", line 24, in perform_run
File "/media/l1nux/SAN240/py3venv/py3swmm/lib/python3.9/site-packages/ostrich_swmm-0.6.0-py3.9.egg/ostrich_swmm/inject.py", line 387, in perform_injection
File "/media/l1nux/SAN240/py3venv/py3swmm/lib/python3.9/site-packages/ostrich_swmm-0.6.0-py3.9.egg/ostrich_swmm/inject.py", line 171, in inject_parameters_into_input
File "/media/l1nux/SAN240/py3venv/py3swmm/lib/python3.9/site-packages/ostrich_swmm-0.6.0-py3.9.egg/ostrich_swmm/inject.py", line 55, in extract_subcatchment_polygons
NameError: name 'sys' is not defined

@rarygit
Copy link
Author

rarygit commented Feb 19, 2022

Solution in file inject.py:

don't use:

if sys.version_info[0] == 3:

instead:

from sys import version_info
if version_info[0] == 3:

This site was helpful:

https://stackoverflow.com/questions/9079036/how-do-i-detect-the-python-version-at-runtime

So now to the next problem: ValueError: Coordinates (1082700.0, 1077400.0) not found in subcatchments.

$ ostrich-swmm run -c submodel-ostrich-swmm-config.json
Traceback (most recent call last):
File "/media/l1nux/SAN240/conda_envs/envs/py3swmm/bin/ostrich-swmm", line 33, in
sys.exit(load_entry_point('ostrich-swmm==0.6.0', 'console_scripts', 'ostrich-swmm')())
File "/media/l1nux/SAN240/conda_envs/envs/py3swmm/lib/python3.9/site-packages/ostrich_swmm/main.py", line 247, in main
return subcommandsargs['subcommand']
File "/media/l1nux/SAN240/conda_envs/envs/py3swmm/lib/python3.9/site-packages/ostrich_swmm/main.py", line 116, in run_cmd
run.perform_run(config)
File "/media/l1nux/SAN240/conda_envs/envs/py3swmm/lib/python3.9/site-packages/ostrich_swmm/run.py", line 24, in perform_run
inject.perform_injection(config, validate=False)
File "/media/l1nux/SAN240/conda_envs/envs/py3swmm/lib/python3.9/site-packages/ostrich_swmm/inject.py", line 388, in perform_injection
inject_parameters_into_input(input_parameters, input_template)
File "/media/l1nux/SAN240/conda_envs/envs/py3swmm/lib/python3.9/site-packages/ostrich_swmm/inject.py", line 173, in inject_parameters_into_input
lid['location']['subcatchment'] = get_subcatchment_from_map_coords(
File "/media/l1nux/SAN240/conda_envs/envs/py3swmm/lib/python3.9/site-packages/ostrich_swmm/inject.py", line 115, in get_subcatchment_from_map_coords
raise ValueError(
ValueError: Coordinates (1082700.0, 1077400.0) not found in subcatchments.

@rarygit
Copy link
Author

rarygit commented Feb 19, 2022

Maybe start with line 351 in file inject.py

line.append(sc_names_list[i]) #need to figure out how to grab subcat coordinates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant