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

Solved import Error of Rasterio | Solved 3 Warnings #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lukasschirren
Copy link

Initially, the model did not run for me, and I had to solve the import error. After that, it ran smoothly.

Import Error of Rasterio

For me, the import of rasterio failed and gave the following error:

from rasterio._version import gdal_version, get_geos_version, get_proj_version 
ImportError: DLL load failed while importing _version: The specified procedure could not be found.

I could solve it by adding the following line before importing other packages in the files optimize_hydrogen_plant, get_weather_data, map_costs:

from osgeo import gdal 

Three Warnings

Three warnings in optimize_hydrogen_plant.py solved:

  • Transforming a non-integer to an integer
  • Resampling is done with lowercase 'h' for hours instead of uppercase 'H'
  • Accessing series by position with .iloc

(get_weather_data, map_costs,
optimize_hydrogen_plant)

Two warnings in optimize_hydrogen_plant.py solved
Accessing series by position with .iloc, and
Non-integer 'periods' in 'pd.date_range'
@samiyhanaqvi
Copy link
Collaborator

Just wondering which rasterio version you had in your environment? I've not had this issue come up on mine and want to investigate whether it is a problem that occurs with a particular version.

@lukasschirren
Copy link
Author

I am using rasterio 1.3.6 with Python version 3.11.8. The given requirement file didn't work for me, so I created my environment.
Importing gdal in the beginning, should not affect other environments, but it solved the import error.

This is how my requirement yml-file looks:

name: geoh2_master
channels:
  - conda-forge
  - defaults
dependencies:
  - affine=2.4.0=pyhd8ed1ab_0
  - asttokens=2.4.1=pyhd8ed1ab_0
  - atlite=0.2.12=pyhd8ed1ab_0
  - attrs=23.2.0=pyh71513ae_0
  - aws-c-auth=0.7.16=h7613915_8
  - aws-c-cal=0.6.10=hf6fcf4e_2
  - aws-c-common=0.9.14=hcfcfb64_0
  - aws-c-compression=0.2.18=hf6fcf4e_2
  - aws-c-event-stream=0.4.2=h3df98b0_6
  - aws-c-http=0.8.1=h4e3df0f_7
  - aws-c-io=0.14.6=hf0b8b6f_2
  - aws-c-mqtt=0.10.3=h96fac68_2
  - aws-c-s3=0.5.2=h08df315_2
  - aws-c-sdkutils=0.1.15=hf6fcf4e_2
  - aws-checksums=0.1.18=hf6fcf4e_2
  - aws-crt-cpp=0.26.3=h6047f0a_2
  - aws-sdk-cpp=1.11.267=h558341a_3
  - blas=1.0=mkl
  - blosc=1.21.3=h6c2663c_0
  - bokeh=3.4.1=pyhd8ed1ab_0
  - boost-cpp=1.82.0=h59b6b97_2
  - bottleneck=1.3.8=py311h59ca53f_0
  - branca=0.7.1=pyhd8ed1ab_0
  - brotli=1.1.0=hcfcfb64_1
  - brotli-bin=1.1.0=hcfcfb64_1
  - brotli-python=1.1.0=py311h12c1d0e_1
  - bzip2=1.0.8=h2bbff1b_5
  - c-ares=1.28.1=hcfcfb64_0
  - ca-certificates=2024.3.11=haa95532_0
  - cairo=1.16.0=haedb8bc_5
  - cartopy=0.23.0=py311hf63dbb6_0
  - cdsapi=0.6.1=pyhd8ed1ab_0
  - certifi=2024.2.2=pyhd8ed1ab_0
  - cfitsio=4.2.0=h9ebe7e4_0
  - cftime=1.6.3=py311h59ca53f_0
  - charset-normalizer=3.3.2=pyhd8ed1ab_0
  - click=8.1.7=win_pyh7428d3b_0
  - click-plugins=1.1.1=py_0
  - cligj=0.7.2=pyhd8ed1ab_1
  - cloudpickle=3.0.0=pyhd8ed1ab_0
  - colorama=0.4.6=pyhd8ed1ab_0
  - comm=0.2.2=pyhd8ed1ab_0
  - contourpy=1.2.1=py311h005e61a_0
  - curl=8.5.0=he2ea4bf_0
  - cycler=0.12.1=pyhd8ed1ab_0
  - cytoolz=0.12.3=py311ha68e1ae_0
  - dask=2024.4.1=pyhd8ed1ab_0
  - dask-core=2024.4.1=pyhd8ed1ab_0
  - dask-expr=1.0.11=pyhd8ed1ab_0
  - debugpy=1.8.1=py311h12c1d0e_0
  - decorator=5.1.1=pyhd8ed1ab_0
  - deprecation=2.1.0=pyh9f0ad1d_0
  - distributed=2024.4.1=pyhd8ed1ab_0
  - exceptiongroup=1.2.0=pyhd8ed1ab_2
  - executing=2.0.1=pyhd8ed1ab_0
  - expat=2.5.0=hd77b12b_0
  - fiona=1.9.1=py311ha4db88c_0
  - folium=0.16.0=pyhd8ed1ab_0
  - fontconfig=2.14.2=hbde0cde_0
  - fonttools=4.51.0=py311ha68e1ae_0
  - freetype=2.12.1=ha860e81_0
  - freexl=1.0.6=h67ca5e6_1
  - fsspec=2024.3.1=pyhca7485f_0
  - gdal=3.6.2=py311h4bd9738_4
  - geopandas=0.14.3=pyhd8ed1ab_0
  - geopandas-base=0.14.3=pyha770c72_0
  - geos=3.11.1=h1537add_0
  - geotiff=1.7.1=hc256dc0_6
  - gettext=0.22.5=h5728263_2
  - gettext-tools=0.22.5=h7d00a51_2
  - glib=2.78.1=h12be248_0
  - glib-tools=2.78.1=h12be248_0
  - hdf4=4.2.15=h1b1b6ef_5
  - hdf5=1.12.2=nompi_h57737ce_101
  - icc_rt=2022.1.0=h6049295_2
  - icu=70.1=h0e60522_0
  - idna=3.6=pyhd8ed1ab_0
  - importlib-metadata=7.1.0=pyha770c72_0
  - importlib_metadata=7.1.0=hd8ed1ab_0
  - iniconfig=2.0.0=pyhd8ed1ab_0
  - intel-openmp=2023.1.0=h59b6b97_46320
  - ipykernel=6.29.3=pyha63f2e9_0
  - ipython=8.22.2=pyh7428d3b_0
  - jedi=0.19.1=pyhd8ed1ab_0
  - jinja2=3.1.3=pyhd8ed1ab_0
  - joblib=1.4.0=pyhd8ed1ab_0
  - jpeg=9e=h2bbff1b_1
  - jupyter_client=8.6.1=pyhd8ed1ab_0
  - jupyter_core=5.7.2=py311h1ea47a8_0
  - kealib=1.5.0=h61be68b_0
  - kiwisolver=1.4.5=py311h005e61a_1
  - krb5=1.21.2=heb0366b_0
  - lcms2=2.12=h83e58a3_0
  - lerc=4.0.0=h63175ca_0
  - libabseil=20240116.1=cxx17_h63175ca_2
  - libaec=1.1.3=h63175ca_0
  - libarrow=15.0.1=h2a83f13_2_cpu
  - libarrow-acero=15.0.1=h63175ca_2_cpu
  - libarrow-dataset=15.0.1=h63175ca_2_cpu
  - libarrow-flight=15.0.1=h02312f3_2_cpu
  - libarrow-flight-sql=15.0.1=h55b4db4_2_cpu
  - libarrow-gandiva=15.0.1=h3f2ff47_2_cpu
  - libarrow-substrait=15.0.1=h89268de_2_cpu
  - libasprintf=0.22.5=h5728263_2
  - libasprintf-devel=0.22.5=h5728263_2
  - libblas=3.9.0=1_h8933c1f_netlib
  - libboost=1.82.0=h3399ecb_2
  - libbrotlicommon=1.1.0=hcfcfb64_1
  - libbrotlidec=1.1.0=hcfcfb64_1
  - libbrotlienc=1.1.0=hcfcfb64_1
  - libcblas=3.9.0=5_hd5c7e75_netlib
  - libcrc32c=1.1.2=h0e60522_0
  - libcurl=8.5.0=h86230a5_0
  - libdeflate=1.17=h2bbff1b_1
  - libevent=2.1.12=h3671451_1
  - libffi=3.4.4=hd77b12b_0
  - libgdal=3.6.2=h8c89b76_4
  - libgettextpo=0.22.5=h5728263_2
  - libgettextpo-devel=0.22.5=h5728263_2
  - libglib=2.78.1=he8f3873_0
  - libgoogle-cloud=2.22.0=h9cad5c0_1
  - libgoogle-cloud-storage=2.22.0=hb581fae_1
  - libgrpc=1.62.1=h5273850_0
  - libiconv=1.17=hcfcfb64_2
  - libintl=0.22.5=h5728263_2
  - libintl-devel=0.22.5=h5728263_2
  - libkml=1.3.0=h63940dd_7
  - liblapack=3.9.0=5_hd5c7e75_netlib
  - libnetcdf=4.8.1=nompi_h8c042bf_106
  - libparquet=15.0.1=h7ec3a38_2_cpu
  - libpng=1.6.39=h8cc25b3_0
  - libpq=15.6=h94c9ec1_0
  - libprotobuf=4.25.3=h503648d_0
  - libre2-11=2023.09.01=hf8d8778_2
  - librttopo=1.1.0=he22b5cd_12
  - libsodium=1.0.18=h8d14728_1
  - libspatialindex=1.9.3=h39d44d4_4
  - libspatialite=5.0.1=hfdcade0_23
  - libsqlite=3.45.2=hcfcfb64_0
  - libssh2=1.10.0=he2ea4bf_2
  - libthrift=0.19.0=ha2b3283_1
  - libtiff=4.5.0=hf8721a0_2
  - libutf8proc=2.8.0=h82a8f57_0
  - libwebp-base=1.3.2=h2bbff1b_0
  - libxml2=2.12.6=hc3477c8_1
  - libzip=1.10.1=h1d365fa_3
  - libzlib=1.2.13=hcfcfb64_5
  - linopy=0.3.8=pyhd8ed1ab_0
  - locket=1.0.0=pyhd8ed1ab_0
  - lz4=4.3.3=py311haddf500_0
  - lz4-c=1.9.4=h2bbff1b_0
  - m2w64-gcc-libgfortran=5.3.0=6
  - m2w64-gcc-libs=5.3.0=7
  - m2w64-gcc-libs-core=5.3.0=7
  - m2w64-gmp=6.1.0=2
  - m2w64-libwinpthread-git=5.0.0.4634.697f757=2
  - mapclassify=2.6.1=pyhd8ed1ab_0
  - markupsafe=2.1.5=py311ha68e1ae_0
  - matplotlib-base=3.8.4=py311h6e989c2_0
  - matplotlib-inline=0.1.6=pyhd8ed1ab_0
  - minizip=4.0.3=hb68bac4_0
  - mkl=2023.1.0=h6b88ed4_46358
  - mkl-service=2.4.0=py311h2bbff1b_1
  - mkl_fft=1.3.8=py311h2bbff1b_0
  - mkl_random=1.2.4=py311h59b6b97_0
  - msgpack-python=1.0.7=py311h005e61a_0
  - msys2-conda-epoch=20160418=1
  - munch=4.0.0=pyhd8ed1ab_0
  - munkres=1.1.4=pyh9f0ad1d_0
  - nest-asyncio=1.6.0=pyhd8ed1ab_0
  - netcdf4=1.6.2=nompi_py311h45b207f_100
  - networkx=3.3=pyhd8ed1ab_1
  - numexpr=2.8.7=py311h1fcbade_0
  - numpy=1.26.4=py311hdab7c0b_0
  - numpy-base=1.26.4=py311hd01c5d8_0
  - openjpeg=2.5.0=ha2aaf27_2
  - openssl=3.2.1=hcfcfb64_1
  - orc=2.0.0=heb0c069_0
  - packaging=24.0=pyhd8ed1ab_0
  - pandas=2.2.2=py311hf63dbb6_0
  - parso=0.8.4=pyhd8ed1ab_0
  - partd=1.4.1=pyhd8ed1ab_0
  - pcre2=10.40=h17e33f8_0
  - pickleshare=0.7.5=py_1003
  - pip=23.3.1=py311haa95532_0
  - pixman=0.40.0=h2bbff1b_1
  - platformdirs=4.2.0=pyhd8ed1ab_0
  - pluggy=1.4.0=pyhd8ed1ab_0
  - ply=3.11=pyhd8ed1ab_2
  - poppler=22.12.0=h0bf3bde_3
  - poppler-data=0.4.11=haa95532_1
  - postgresql=15.6=h94c9ec1_0
  - progressbar2=4.4.2=pyhd8ed1ab_0
  - proj=9.1.1=heca977f_2
  - prompt-toolkit=3.0.42=pyha770c72_0
  - psutil=5.9.8=py311ha68e1ae_0
  - pure_eval=0.2.2=pyhd8ed1ab_0
  - pyarrow=15.0.1=py311h6a6099b_2_cpu
  - pyarrow-hotfix=0.6=pyhd8ed1ab_0
  - pygments=2.17.2=pyhd8ed1ab_0
  - pyomo=6.6.1=py311h12c1d0e_0
  - pyparsing=3.1.2=pyhd8ed1ab_0
  - pypsa=0.27.1=pyhd8ed1ab_0
  - pyshp=2.3.1=pyhd8ed1ab_0
  - pysocks=1.7.1=pyh0701188_6
  - pytables=3.7.0=py311h360bcb6_3
  - pytest=8.1.1=pyhd8ed1ab_0
  - python=3.11.8=he1021f5_0
  - python-tzdata=2024.1=pyhd8ed1ab_0
  - python-utils=3.8.2=pyhd8ed1ab_0
  - python_abi=3.11=2_cp311
  - pytz=2024.1=pyhd8ed1ab_0
  - pywin32=306=py311h12c1d0e_2
  - pyyaml=6.0.1=py311ha68e1ae_1
  - pyzmq=25.1.2=py311h9250fbb_0
  - qhull=2020.2=h59b6b97_2
  - rasterio=1.3.6=py311hc06ee40_0
  - re2=2023.09.01=hd3b24a8_2
  - requests=2.31.0=pyhd8ed1ab_0
  - rtree=1.2.0=py311hcacb13a_0
  - scikit-learn=1.4.2=py311h142b183_0
  - scipy=1.13.0=py311h0b4df5a_0
  - setuptools=68.2.2=py311haa95532_0
  - six=1.16.0=pyh6c4a22f_0
  - snappy=1.1.10=hfb803bf_1
  - snuggs=1.4.7=py_0
  - sortedcontainers=2.4.0=pyhd8ed1ab_0
  - sqlite=3.41.2=h2bbff1b_0
  - stack_data=0.6.2=pyhd8ed1ab_0
  - tbb=2021.8.0=h59b6b97_0
  - tblib=3.0.0=pyhd8ed1ab_0
  - threadpoolctl=3.4.0=pyhc1e730c_0
  - tiledb=2.13.2=h3132609_0
  - tk=8.6.12=h2bbff1b_0
  - tomli=2.0.1=pyhd8ed1ab_0
  - toolz=0.12.1=pyhd8ed1ab_0
  - tornado=6.4=py311ha68e1ae_0
  - tqdm=4.66.2=pyhd8ed1ab_0
  - traitlets=5.14.2=pyhd8ed1ab_0
  - typing_extensions=4.11.0=pyha770c72_0
  - tzdata=2024a=h04d1e81_0
  - ucrt=10.0.22621.0=h57928b3_0
  - uriparser=0.9.7=h2bbff1b_0
  - urllib3=2.2.1=pyhd8ed1ab_0
  - validators=0.28.0=pyhd8ed1ab_0
  - vc=14.2=h21ff451_1
  - vc14_runtime=14.38.33130=h82b7239_18
  - vs2015_runtime=14.38.33130=hcb4865c_18
  - wcwidth=0.2.13=pyhd8ed1ab_0
  - wheel=0.41.2=py311haa95532_0
  - win_inet_pton=1.1.0=pyhd8ed1ab_6
  - xarray=2024.3.0=pyhd8ed1ab_0
  - xerces-c=3.2.4=hd77b12b_1
  - xyzservices=2024.4.0=pyhd8ed1ab_0
  - xz=5.4.6=h8cc25b3_0
  - yaml=0.2.5=h8ffe710_2
  - zeromq=4.3.5=h63175ca_1
  - zict=3.0.0=pyhd8ed1ab_0
  - zipp=3.17.0=pyhd8ed1ab_0
  - zlib=1.2.13=hcfcfb64_5
  - zstd=1.5.5=hd43e919_0
  - pip:
      - et-xmlfile==1.1.0
      - geographiclib==2.0
      - geopy==2.4.1
      - openpyxl==3.1.2
      - pillow==10.3.0
      - pyasn1==0.6.0
      - pyproj==3.6.1
      - pysimplegui==5.0.4
      - python-dateutil==2.9.0.post0
      - rsa==4.9
      - shapely==2.0.3
      - xlsxwriter==3.2.0

@samiyhanaqvi
Copy link
Collaborator

Thanks for this, Lukas.

Which OS do you use and did this issue come up when you were using the repo's environment or your own environment?

@lukasschirren
Copy link
Author

Hey Sami, my OS is Windows 11 Pro.
Initially, I tried it with the given environment in the repository, but that didn't work for me. After that, I created my environment with a newer version of Python than was proposed.

Adding the line "from osgeo import gdal" does not affect the code/model/performance, but just imports a package which is already existent in the current environment. It could be beneficial for users who want to use their environment because this error does not appear.

@samiyhanaqvi
Copy link
Collaborator

I appreciate this information, as I'm trying to understand how your issue came about in the first place as I have others who use Windows and their own environments and they have not had this issue. This understanding will just make it easier for documentation of the code.

When the ImportError came up, were you using the repo's environment or with your own environment?

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

Successfully merging this pull request may close these issues.

2 participants