modflowpy / flopy

A Python package to create, run, and post-process MODFLOW-based models.
https://flopy.readthedocs.io
Other
517 stars 313 forks source link

bug: OSError: [WinError 6] The handle is invalid #1575

Closed LoganJaySwenson closed 11 months ago

LoganJaySwenson commented 2 years ago

Hi everyone, I'm trying to reproduce the Flopy example in Bakker et al. (2016). I'm running into an error where it seems that Flopy cannot open the mf2005.exe on my computer in the model.run_model() command. Python sees the mf2005.exe in my directory, but for some reason I cannot point the command to access it. I've been following along with this script.

I'm using a 64-bit Windows OS. Python 3.9.12 flopy 3.3.5 numpy 1.21.5

The following is my code to reproduce the error: import numpy as np import flopy.modflow as fpm import flopy.utils as fpu

path_to_mf2005 = 'C:/Users/Logan/models/MF2005.1_12/bin/mf2005.exe' model = fpm.Modflow(modelname = 'gwexample', exe_name=path_to_mf2005)

fpm.ModflowDis(model, nlay=1, nrow=1, ncol=201, delr=10, delc=1, top=50, botm=0)

ibound = np.ones((1, 201)) ibound[0, 0] = ibound[0, -1] = -1 fpm.ModflowBas(model, ibound=ibound, strt=20)

fpm.ModflowLpf(model, hk=10, laytyp=1)

fpm.ModflowRch(model, rech=0.001) lrcQ = { 0: [[0, 0, 50, -1], [0, 0, 150, -1]]} fpm.ModflowWel(model, stress_period_data=lrcQ)

fpm.ModflowPcg(model)

fpm.ModflowOc(model)

model.write_input()

model.run_model() Output: FloPy is using the following executable to run the model: C:/Users/Logan/models/MF2005.1_12/bin/mf2005.exe OSError: [WinError 6] The handle is invalid

Any help on how to fix this issue would be greatly appreciated!

Cheers, Logan

wpbonelli commented 1 year ago

@LoganJaySwenson some recent work has updated exe path handling/testing but it has not made it into a release yet. The development version of FloPy can be installed from the develop branch with e.g. pip install https://github.com/modflowpy/flopy/archive/develop.zip, could you confirm whether your issue persists after updating?

wpbonelli commented 11 months ago

tentatively closing, but please reopen if you still encounter issues with the latest flopy