hyriver / pynhd

A part of HyRiver software stack that provides access to NHD+ V2 data through NLDI and WaterData web services
https://docs.hyriver.io
Other
33 stars 8 forks source link

Cannot load module WaterData #80

Closed ehinman closed 3 weeks ago

ehinman commented 3 weeks ago

What happened?

I am trying to import the WaterData module from pynhd. I am getting an error message and the module fails to load.

What did you expect to happen?

I expected the module to load with no issues.

Minimal Complete Verifiable Example

# I have a yaml (environment-dev.yml) file that looks like this:
name: hyswap-dev-environment
channels:
  - conda-forge
dependencies:
  - numpy
  - pandas
  - scipy
  - sphinx
  - pytest
  - coverage
  - flake8
  - pylint
  - dataretrieval
  - matplotlib
  - folium
  - mapclassify
  - pynhd
  - tqdm
  - pydeps==1.12.3
  - pip
  - nbsphinx
  - sphinx-rtd-theme
  - ipykernel
  - jupyter
  - pip:
    - datetime
    - nbsphinx_link
    - pydocstringformatter

# I recently reinstalled miniforge on my computer via Homebrew (this morning), and I ran:
# mamba env create -f environment-dev.yml
# I then tried to run the following:

from pynhd import WaterData

MVCE confirmation

Relevant log output

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 6
      4 import matplotlib.pyplot as plt
      5 import matplotlib.patches
----> 6 from pynhd import WaterData
      7 import warnings
      8 warnings.filterwarnings('ignore')

File /opt/homebrew/Caskroom/miniforge/base/envs/hyswap-dev-environment/lib/python3.13/site-packages/pynhd/__init__.py:7
      5 from .network_tools import prepare_nhdplus, topoogical_sort, vector_accumulation
      6 from .print_versions import show_versions
----> 7 from .pynhd import NLDI, NHDPlusHR, WaterData
      9 try:
     10     __version__ = get_distribution(__name__).version

File /opt/homebrew/Caskroom/miniforge/base/envs/hyswap-dev-environment/lib/python3.13/site-packages/pynhd/pynhd.py:10
      8 import pygeoogc as ogc
      9 import pygeoutils as geoutils
---> 10 from pygeoogc import WFS, ArcGISRESTful, MatchCRS, RetrySession, ServiceURL
     11 from requests import Response
     12 from shapely.geometry import MultiPolygon, Polygon

ImportError: cannot import name 'MatchCRS' from 'pygeoogc' (/opt/homebrew/Caskroom/miniforge/base/envs/hyswap-dev-environment/lib/python3.13/site-packages/pygeoogc/__init__.py)

Anything else we need to know?

Thanks for your help, I am fairly certain this is user error of some kind, but unsure what I've done.

Environment

I'm not sure how to run this line. I just tried to run import pynhd and I got the same error as reported above. Here are the versions, manually:

pynhd 0.2.0 pygeoogc 0.15.1
cheginit commented 3 weeks ago

You have installed a very old version of pynhd, 0.2.0. Please update to the latest HyRiver version series, 0.18.x.

ehinman commented 3 weeks ago

Ah ok, thanks. Do I need to force the version for conda to automatically install a newer version? Is 0.2.0 an official release or something?

cheginit commented 3 weeks ago

I'd just create a new env and set min version of all HyRiver packages to 0.18, e.g., pynhd >=0.18. This should fix all version conflict issues.

ehinman commented 3 weeks ago

I will close this issue now; I was able to solve my problems. One thing to be aware of: I use miniforge to create my python environments. If a python version is not specified, it automatically installs python 3.13. python 3.13 appears to have a conflict with the version of pyarrow needed for pynhd 0.18.0. Additionally, if you do not specify a version of pynhd when using python 3.13, it automatically installs pynhd 0.2.0. I have to specify that the environment uses python<3.13 to get everything to install and import correctly. Thank you for your support!

cheginit commented 3 weeks ago

I see. That's strange. Version 0.2.0 was released 4 years ago! I am guessing it has to do with geopandas>=1.