Installed gurobi , not refelecting when importing - gurobi

I have installed gurobi, however it does not get reflected when importing.
I get the following error:
No module name gurobi

You didn't write which API you are using. If you are using python, you should use import gurobipy and not gurobi. You also need to setup some environment variables (GUROBI_HOME, PATH and LD_LIBRARY_PATH). See Gurobi quick start guide.

Related

How to import cplex.jl on google colab

I need to create a optimization problem with the cplex library and julia. I have to use colab for this, I was able to create a colab on the julia template and download the JuMP library. I have a student license on cplex. But when I try to download cplex it gives the following error:
Error building `CPLEX`:
ERROR: LoadError: Unable to install CPLEX.jl.
The versions of CPLEX supported by CPLEX.jl are:
* 12.10
* 20.1
You must download and install one of these versions separately.
You should set the `CPLEX_STUDIO_BINARIES` environment variable to point to
the install location then try again. For example (updating the path to the
correct location if needed):
# On Windows, this might be
ENV["CPLEX_STUDIO_BINARIES"] = "C:\\Program Files\\CPLEX_Studio1210\\cplex\\bin\\x86-64_win\\"
import Pkg
Pkg.add("CPLEX")
Pkg.build("CPLEX")
i tried the import Pkg; Pkg.add("CPLEX") and upload the I uploaded the cplex files on the computer and showed the path there:
ENV["CPLEX_STUDIO_BINARIES"] = "/content/x64_win64"
import Pkg
Pkg.add("CPLEX")
Pkg.build("CPLEX")

Installed modules not found, but show up in python interpreter config

I tried to install EZGmail module for Python. When I check my interpreter settings, it shows it as installed in the PyCharm list. I then use this same interpreter for my project, but I get a module not found error when trying to import EZGmail. What should I check?
Looks like you're trying to import the module in a different casing than it's mentioned on the document.
You're trying to do:
import EZGmail
while the Quickstart document says:
import ezgmail

DLL load failed _multiarray_unmath when importing numpy

I installed Numpy v. 1.18.4 and Python 3.8. These are the latest as of 5/2020 I think. I get the error:
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.8 from "C:\Users\SScott1\.conda\envs\cartoenv7_3_8\python.exe"
* The NumPy version is: "1.18.4"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
Is there a place I can report this? How do I resolve this error.
This happens when you launch VS Code outside of Anaconda Navigator.
This question already has a few answers here and here. Adding this to the environment path worked for me:
C:\Users\ <username> \Anaconda3\Library\bin

Setting MIP and NLP solvers path using Pyomo MindtPySolver

I am using Pyomo 5.6.8 and trying to resolve a non linear optimization problem using MindtPySolver.
I have no issue on my local machine, simply calling the solve method with these arguments:
SolverFactory('mindtpy').solve(model, mip_solver='cbc', nlp_solver='ipopt')
However, when I go cloud on Azure, Pyomo doesn't get the path to the CBC and IPOPT solvers. When needing to resolve a problem that is linear, I can bypass the issue using the following command, by adding executable argument when creating SolverFactory instance with a LP solver:
SolverFactory("cbc", executable="/path/to/my/virtual/env/bin/cbc")
In my non-linear programming case, MindtpySolver doesn't accept additional argument. I looked at the doc & source code and couldn't find option to specify solver path, that is unfortunately not recognized by default on my Azure environment.
I tried to pass options using the "solver_args" options found on source code like this:
SolverFactory('mindtpy').solve(
model,
nlp_solver_args={
"executable": "/path/to/my/virtual/env/bin/ipopt"
},
mip_solver_args={
"executable": "/path/to/my/virtual/env/bin/cbc"
},
mip_solver='cbc', nlp_solver='ipopt',
)
But I'm still getting "WARNING: Could not locate the 'ipopt' executable, which is required for solver" like errors. I insist on the fact that all solvers (here cbc and ipopt) can be found in my virtual environment.
Is there a way to specify solvers path using MindtPySolver?
I may have same issue too, My optimize problem is Mixed-Integer Nonlinear Programs, and it have to using "SolverFactory('mindtpy').solve(model, mip_solver='glpk', nlp_solver='ipopt')" And the solver is in Django Framework with Apache2 WSGI Service which WSGIDaemonProcess : Conda Env.
When call api via Web Browser. It will rise error like cannot find "ipopt" solver. and "glpk" solver too. and SolverFactory allow us set only one Executable.
BTW, Already find out how to fix it.
After you install ipopt and plugin solver via Conda install.
Just going deep in python package and edit raw file.
My path are below:
/home/user/miniconda3/envs/py385/lib/python3.8/site-packages/pyomo/solvers/plugins/solvers/GLPK.py
/home/user/miniconda3/envs/py385/lib/python3.8/site-packages/pyomo/solvers/plugins/solvers/IPOPT.py
Find function below and change it.
def _default_executable(self):
executable = Executable('/home/user/miniconda3/envs/py385/bin/glpsol')
def _default_executable(self):
executable = Executable("/home/user/miniconda3/envs/py385/bin/ipopt")
You can find where is plugin solver located by type in terminal command
"which ipopt", "which glpsol"

No module named lstm_predictor

When I am trying to import the following module,
>>> from lstm_predictor import lstm_model
The error says no module named lstm_predictor.
How can I solve the problem?
It seems like you are utilizing the lstm_predictor package present in https://github.com/tgjeon/TensorFlow-Tutorials-for-Time-Series.
Since this is not a standard module, make sure you have cloned this project and you have the lstm_predictor.py file in the same folder as your python terminal.