I have been using a SCIPAMPL solver in Pyomo framework for a MINLP problem. I have created a streamlit app and is working perfectly on my local machine. However when I try deploying the app it throws an error that the solver could not be found. I already have the scipampl .py and .exe files installed.
There’s a similar post for GLPK solver which tells us the dependencies required for GLPK solver. Using PYOMO + GLPK on Streamlit Share - Deploying on Streamlit Cloud - Streamlit Could you please suggest the same for scipampl solver.
Hi @akhileshgarude, welcome to the forum!
I’m not particularly familiar with that solver, but the installation instructions https://www.scipopt.org/index.php#download mention that you may be able to use conda to install the suite.
More details here GitHub - conda-forge/scipoptsuite-feedstock: A conda-smithy repository for scipoptsuite.
If you add an environment.yml file with these entries
And any other python packages in it, that might work for you.
Hi @blackary thanks for your reply. I am actually new to both Streamlit and GitHub. Could yoy please help me where do I need to add yml file. I have currently added packages.txt and requirements.txt in my GitHub repository. Can I add these dependencies in these 2 files?
@akhileshgarude Here’s what each of those is for:
requirements.txt – for installing python packages with pip
packages.txt – for installing linux packages with apt
environment.yml – for installing python package or other packages with conda
My recommendation is to remove
requirements.txt and replace it with
environment.yml. It’s very likely possible to also use requirements.txt + packages.txt, but I couldn’t figure out what packages you would need to use that solver. I would recommend trying it with environment.yml, where you start with the packages I listed, and add anything else you need from your requirements.txt. e.g.
- requests (or whatever other packages you need)
Hi @blackary these are the packages I will be needing.
I tried replacing the requirements.txt file with the yml file in the following way.
However I am getting a error message 'No module named ‘pyomo’.
Is there any different way where I can install pyomo. I am able to install pyomo in the command prompt using conda install -c conda-forge pyomo.
@blackary request your help on this. I have been really struggling on this for the last week.
@akhileshgarude Sorry for the slow response. Could you please share the repository with your code?
I have made you the collaborator of the repository.
@akhileshgarude Can you try the following environment.yml and see if it works?
@blackary I am getting the following error after making the changes in the yml file.
Hi @akhileshgarude, it appears that you didn’t actually copy the environment that I suggested. Could you merge my PR in and see if that works?
Hi @blackary I had done these changes yesterday but is giving an error as shown in the screenshot.
@akhileshgarude The error message I was seeing seemed very strange to me, so I thought I’d delete and redeploy the app. Unfortunately, I don’t have permission to deploy – could you try redeploying just to check?
Nevermind – I tried it with just the environment.yml, and it failed. I’ll see if I can figure something out.
Hi @blackary I am able to configure the yml file after removing streamlit and mamba but still it is giving an error with the solver as before.
This line is the one that is failing
This is either because that file doesn’t exist, or more likely because this app is running on linux, and it can’t execute a .exe file. Can you try removing that argument, and making the line just be
Hi @blackary I tried running without specifying the exe part but again it is giving the same error. It is not an issue with the SCIP solver as I tried with a different solver but again gave the same issue.
I am now trying to run the exe using subprocess as suggested in the below link but don’t know how to exactly use it.
Expose executables from path to streamlit/scope? - Using Streamlit - Streamlit
Also I have kept the exe file in the main repository.
Hi @blackary what do you think can be done? I have also added the linux versions of the solver but again giving the same error.
I just looked at the recent logs, and it actually is a different error than before, now it is showing errors like ```
Failed to set executable for solver asl. File with name=sciptgz.tgz either does not exist or it is not executable. To skip this validation, call set_executable with validate=False.
Can you please share the whole error that is happening if you don’t specify any executable? (like this
Here’s the complete error message without specifying any executable.
2022-12-02 17:15:17.341 Failed to create solver with name ‘scipampl’:
Failed to set executable for solver asl. File with name=scipampl either does not exist or it is not executable. To skip this validation, call set_executable with validate=False.
Traceback (most recent call last):
File “/home/appuser/venv/lib/python3.9/site-packages/pyomo/opt/base/solvers.py”, line 166, in call
opt = self._cls_implicit_solvers[mode]
File “/home/appuser/venv/lib/python3.9/site-packages/pyomo/solvers/plugins/solvers/ASL.py”, line 44, in init
File “/home/appuser/venv/lib/python3.9/site-packages/pyomo/opt/solver/shellcmd.py”, line 56, in init
File “/home/appuser/venv/lib/python3.9/site-packages/pyomo/opt/solver/shellcmd.py”, line 104, in set_executable
ValueError: Failed to set executable for solver asl. File with name=scipampl either does not exist or it is not executable. To skip this validation, call set_executable with validate=False.
2022-12-02 17:15:17.343 Uncaught app exception
Traceback (most recent call last):
File “/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 564, in _run_script
File “/app/temp2/dynamictest_streamlit_deploy.py”, line 459, in
File “/home/appuser/venv/lib/python3.9/site-packages/pyomo/opt/base/solvers.py”, line 106, in solve
File “/home/appuser/venv/lib/python3.9/site-packages/pyomo/opt/base/solvers.py”, line 123, in _solver_error
raise RuntimeError(“”"Attempting to use an unavailable solver.
RuntimeError: Attempting to use an unavailable solver.
The SolverFactory was unable to create the solver “scipampl”
and returned an UnknownSolver object. This error is raised at the point
where the UnknownSolver object was used as if it were valid (by calling
The original solver was created with the following parameters: