-
Notifications
You must be signed in to change notification settings - Fork 2
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
open_database error #39
Comments
Dear @BjoerndalM , can you tell us the steps before you run the code? What install steps are you using and what's the python package version. Maybe also include the windows OS version. Thanks. |
I am using the Spyder IDE, and running Python 3.9.7. The mikeplys libary was installed using the link: https://github.com/DHI/mikepluspy/archive/refs/tags/v2024.0-latest.zip |
I have tried uninstalling both the 2021 version and 2023 version of MIKE+, meaning i now only have the MIKE Urban 2020 version and MIKE+ 2024 version installed. When trying to use other functions from the mikepluspy libary i get errors as well, such as this one when i am trying to run the 1d Engine: Failed to initialize pythonnet: System.InvalidOperationException: This property must be set before runtime is initialized |
@BjoerndalM I think the latest runtime error is not related to mikepluspy package. Please check this link as a reference. https://stackoverflow.com/questions/76214672/failed-to-initialize-python-runtime-dll#:~:text=To%20resolve%20this%2C%20go%20to%20the%20virtual%20environment,the%20python%20code%20again%20to%20see%20its%20working%21 |
@wuwwen I tried following the stackoverflow link that you send me. |
@BjoerndalM i think you are using the wrong version. If you installed MIKE+ 2024 update 1, please use below way to install mikepluspy: Based on the error message, i think you have MIKE+ 2024 software installed, but used mikepluspy of 2024 update 1 version. |
@wuwwen You were right about the mix up of versions, but using the correct version (MIKE+ 2024), means that i am back to the problem that i originally posted, regarding the missing DHI.Amelia.Services |
@wuwwen I asked a colleague to tried to run the code, and he got the excact same error, about the missing files. Like i said earlier, i dont have any files named DHI.Amelia.DataModule.Services.dll, neither does my colleague. |
Hi @wuwwen, I encountered the same issue when trying to open the database. Interestingly, I found that this issue only occurs if mikeio is also installed at the same time as mikepluspy and imported into the script. Removing the import mikeio from the script allows the database connection to open successfully. Here are the details of my environment:
Please let me know if you would like more details. Thanks! |
@bemaDHI Try to import mikecore instead of mikeio. I would assume that creates the same problem, but then at least we have narrowed down where this problem comes from. |
@ecomodeller I managed to run the the open database function and run the model when not importing MIKEIO, I dont know if this help you narrow it down further. |
Thanks @BjoerndalM, this is clearly not ideal. @JesperGr any thoughts on why this interference is happening? |
mikecore-python and mikepluspy are both based on some common files. If they provide the same files in different versions, that can produce compatibility issues. |
@ecomodeller Knowing the cause the issue is the first step. |
@BjoerndalM Not sure I will be of much help, since this problem is not really caused by Python, but conflicts of binary dependencies. But if you describe the use case, where you need both |
@BjoerndalM Can you try a thing: Find where the mikecore-python package is installed on your computer. You can find where the packages are installed in general with the command
Then find the mikecore package and its bin folder, mine is something like:
There should be 15 files there. Then go to the installation folder of MIKE+, ususally something like:
find the same 15 files and copy them to the mikecore-python folder. Do remember to take a backup before copying, just in case. That might solve your issue. |
@ecomodeller sure thing, we can give it a go !
So basicly the loop is: simulating (mikepluspy), reading results (mikeio) and changing the sqlite file (mikepluspy). |
@BjoerndalM Just making sure: You are using mikeio only, and not mikeio1d for reading results? Because mikeio1d has a similar, larger, set of binary files. |
@JesperGr I just tried coping the 15 files from the mike+ folder to the mikecore folder. That being said, if i run the code with mikeio1d imported, the simulation is successfull. |
For res1d files you will need mikeio1d. The mikeio and mikecore will not help there, as they are for the other dfs0+1+2+3+u result files. So, that means that you are up and running now then? |
@JesperGr Yeah i dont think i necessarily need to manipulate any of the dfsX files. Or i can atleast work around that. Thanks |
@BjoerndalM Thanks for followup up. @wuwwen We still need to investigate what causes the incompatibility with the mikecore-Python package and how to work around it, do you agree? |
@JesperGr yes, I agree. I can have a look. But at least we should have a release version which all the DHI python package with the same version. |
@wuwwen the mikeio1d package is able to pick up the required libraries from an external folder, e.g. you can point to a MIKE+ installation, and then it will use the files from there. That would work out for mikecore-python as well, I would guess. |
@JesperGr mikepluspy already pointed into the installation. It has used MikeImport.Setup() method to point to the correct version installation location. Did latest mikeio1d using the mike update 1 binaries? If it is, it must can work with latest mikepluspy. |
When trying to open a database i get the error:
SQLiteException: code = Error (1), message = System.Data.SQLite.SQLiteException (0x800007BF): SQL logic error
Det angivne modul blev ikke fundet.
ved DHI.Amelia.DataModule.Services.DataSource.DataSourceSpatiaLite.OpenDatabaseCore()
ved DHI.Amelia.DataModule.Services.DataSource.BaseDataSource.OpenDatabase()
the code look like this:
from mikeplus import DataTableAccess
from pathlib import Path
sti_db = Path('C:\Users......\Test.sqlite')
db = DataTableAccess(sti_db)
db_open = db.open_database()
The database has been made in a 2024 version of the mike+ program.
The text was updated successfully, but these errors were encountered: