hyriver / pygeohydro

A part of HyRiver software stack for accessing hydrology data through web services
https://docs.hyriver.io
Other
68 stars 23 forks source link

ImportError: DLL load failed: The specified procedure could not be found. #105

Closed Zihaobian closed 1 year ago

Zihaobian commented 1 year ago

What happened?

I just installed Pygeohydro on my Anaconda by using Conda install prompt. When I imported this package, this issue happened.

What did you expect to happen?

No response

Minimal Complete Verifiable Example

No response

MVCE confirmation

Relevant log output

ImportError                               Traceback (most recent call last)
<ipython-input-3-9e1575f9c961> in <module>
----> 1 import pygeohydro

C:\Anaconda\lib\site-packages\pygeohydro\__init__.py in <module>
      4 from .exceptions import InvalidInputRange, InvalidInputType, InvalidInputValue, ZeroMatched
      5 from .print_versions import show_versions
----> 6 from .pygeohydro import (
      7     NID,
      8     NWIS,

C:\Anaconda\lib\site-packages\pygeohydro\pygeohydro.py in <module>
     14 import pandas as pd
     15 import pygeoogc as ogc
---> 16 import pygeoutils as geoutils
     17 import rasterio as rio
     18 import xarray as xr

C:\Anaconda\lib\site-packages\pygeoutils\__init__.py in <module>
      4 from .exceptions import InvalidInputType, InvalidInputValue
      5 from .print_versions import show_versions
----> 6 from .pygeoutils import MatchCRS, arcgis2geojson, gtiff2xarray, json2geodf
      7 
      8 try:

C:\Anaconda\lib\site-packages\pygeoutils\pygeoutils.py in <module>
     14 import orjson as json
     15 import pyproj
---> 16 import rasterio as rio
     17 import rasterio.mask as rio_mask
     18 import rasterio.transform as rio_transform

C:\Anaconda\lib\site-packages\rasterio\__init__.py in <module>
     20             pass
     21 
---> 22 from rasterio._base import gdal_version
     23 from rasterio.drivers import is_blacklisted
     24 from rasterio.dtypes import (

ImportError: DLL load failed: The specified procedure could not be found.

Anything else we need to know?

I change the Python version to 3.6 and this issue can be solved. However, a new issue happen. AttributeError Traceback (most recent call last)

in ----> 1 import pygeohydro C:\Anaconda\envs\env\lib\site-packages\pygeohydro\__init__.py in 1 from pkg_resources import DistributionNotFound, get_distribution 2 ----> 3 from . import helpers, plot 4 from .exceptions import InvalidInputRange, InvalidInputType, InvalidInputValue 5 from .print_versions import show_versions C:\Anaconda\envs\env\lib\site-packages\pygeohydro\helpers.py in 5 import numpy as np 6 import pandas as pd ----> 7 from pygeoogc import RetrySession 8 9 C:\Anaconda\envs\env\lib\site-packages\pygeoogc\__init__.py in 24 25 if sys.platform.startswith("win"): ---> 26 asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) AttributeError: module 'asyncio' has no attribute 'WindowsSelectorEventLoopPolicy' ### Environment
0.11.0
cheginit commented 1 year ago

This issue is related to rasterio installation on Windows. Did you use pip to install any package in addition to using Conda? This issue usually happens when you combine using pip and conda. Additionally, you can try creating a new Python env using conda and only install pygeohydro to check if this issue still exists. Note that HyRiver packages require Python 3.8+. You can use conda create -n test_env pygeohydro.

Zihaobian commented 1 year ago

Thanks for your quick response. I create a new environment with conda create -n myenv python After a new Python 3.11 environment is created, I installed only pygeohydro with conda install -c conda-forge pygeohydro However, this issue still exist.

ImportError Traceback (most recent call last) Cell In[1], line 1 ----> 1 import pygeohydro

File C:\Anaconda\envs\myenv\Lib\site-packages\pygeohydro__init__.py:4 1 """Top-level package for PyGeoHydro.""" 2 from importlib.metadata import PackageNotFoundError, version ----> 4 from pygeohydro import helpers, plot 5 from pygeohydro.exceptions import ( 6 DataNotAvailableError, 7 DependencyError, (...) 15 ZeroMatchedError, 16 ) 17 from pygeohydro.helpers import get_us_states

File C:\Anaconda\envs\myenv\Lib\site-packages\pygeohydro\plot.py:21 19 from pygeohydro import helpers 20 from pygeohydro.exceptions import InputTypeError ---> 21 from pygeohydro.nwis import NWIS 22 from pygeoogc import utils as ogc_utils 24 if TYPE_CHECKING:

File C:\Anaconda\envs\myenv\Lib\site-packages\pygeohydro\nwis.py:26 23 import xarray as xr 25 import async_retriever as ar ---> 26 import pynhd 27 from pygeohydro.exceptions import ( 28 DataNotAvailableError, 29 InputTypeError, 30 InputValueError, 31 ZeroMatchedError, 32 ) 33 from pygeoogc import ServiceURL

File C:\Anaconda\envs\myenv\Lib\site-packages\pynhd__init__.py:4 1 """Top-level package for PyNHD.""" 2 from importlib.metadata import PackageNotFoundError, version ----> 4 from pynhd.core import AGRBase, GeoConnex, ScienceBase 5 from pynhd.exceptions import ( 6 DependencyError, 7 InputRangeError, (...) 14 ZeroMatchedError, 15 ) 16 from pynhd.network_tools import ( 17 NHDTools, 18 enhd_flowlines_nx, (...) 28 vector_accumulation, 29 )

File C:\Anaconda\envs\myenv\Lib\site-packages\pynhd\core.py:12 10 import geopandas as gpd 11 import pandas as pd ---> 12 import pygeoutils as geoutils 13 import pyproj 14 import shapely

File C:\Anaconda\envs\myenv\Lib\site-packages\pygeoutils__init__.py:4 1 """Top-level package for PyGeoUtils.""" 2 from importlib.metadata import PackageNotFoundError, version ----> 4 from pygeoutils._utils import get_gtiff_attrs, get_transform, transform2tuple, xd_write_crs 5 from pygeoutils.exceptions import ( 6 EmptyResponseError, 7 InputRangeError, (...) 14 UnprojectedCRSError, 15 ) 16 from pygeoutils.geotools import ( 17 Coordinates, 18 GeoBSpline, (...) 26 snap2nearest, 27 )

File C:\Anaconda\envs\myenv\Lib\site-packages\pygeoutils_utils.py:11 9 import numpy as np 10 import pyproj ---> 11 import rasterio as rio 12 import rasterio.transform as rio_transform 13 import rioxarray._io as rxr

File C:\Anaconda\envs\myenv\Lib\site-packages\rasterio__init__.py:28 24 os.add_dll_directory(os.path.abspath(p)) 27 from rasterio._show_versions import show_versions ---> 28 from rasterio._version import gdal_version, get_geos_version, get_proj_version 29 from rasterio.crs import CRS 30 from rasterio.drivers import driver_from_extension, is_blacklisted

ImportError: DLL load failed while importing _version: The specified procedure could not be found.

cheginit commented 1 year ago

Can you try creating a new environment and installing rastrio and gdal only and try to run the offending line:

from rasterio._version import gdal_version, get_geos_version, get_proj_version

I don't have a Windows machine, so I cannot test this.

Zihaobian commented 1 year ago

I tried another time. This time the pygeohydro can be imported without any issues. Thanks! I tested some examples provided on the website. However, not every command works. I will keep trying.