ImportError: No module named gurobipy within Magma script (using Anaconda)

110 views
Skip to first unread message

AJ Vogt

unread,
Mar 22, 2019, 3:37:37 AM3/22/19
to Gurobi Optimization
I am using windows 8.1, Anaconda3 (version 4.6.8) with python version 3.6.7

When I run my Magma script which calls a python script. I get the following error:

> TghtSets := Tight(A,theta);
Computing 0-1 vectors in a  25  dimensional subspace.
Traceback (most recent call last):
  File "FindTightv2.py", line 23, in <module>

ImportError: No module named gurobipy
[5996] Failed to execute script FindTightv2

The associated line in the FindTightv2.py script is:

from gurobipy import *

When I call "from gurobipy import *" within my python shell, (which I navigate to via command prompt) I get no such error.

C:\Windows\System32>python
Python 3.6.7 (default, Feb 28 2019, 07:28:18) [MSC v.1900 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from gurobipy import *
>>>

The following is my path from my environment variables:

C:\gurobi810\win64\bin;C:\ProgramData\Anaconda3;C:\ProgramData\Anaconda3\Library\mingw-w64\bin;C:\ProgramData\Anaconda3\Library\usr\bin;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3\Scripts;C:\gurobi810\win64\python37\lib\gurobipy

Note that these directories are correct. However, when I call %PATH%, I get the following error:

C:\Windows\System32>%PATH%
'C:\gurobi810\win64\bin' is not recognized as an internal or external command,
operable program or batch file.

If I modify the path to:

C:\ProgramData\Anaconda3;C:\ProgramData\Anaconda3\Library\mingw-w64\bin;C:\ProgramData\Anaconda3\Library\usr\bin;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3\Scripts

I get the following error:

C:\Windows\System32>%PATH%
'C:\ProgramData\Anaconda3' is not recognized as an internal or external command,

operable program or batch file.



AJ Vogt

unread,
Mar 22, 2019, 4:32:14 AM3/22/19
to Gurobi Optimization
I think I may have found the key issue. When I click the pysetup.bat file in C:\gurobi810\win64\bin, the cmd shell reads:

Python installation directory (hit ENTER to use c:\Python27):

Which is a file directory that doesn't exist nor is pointed to in my path environment. Of course, I get an error simply hitting enter. If I instead input:

Python installation directory (hit ENTER to use c:\Python27): C:\ProgramData\Ana
conda3

running install
running build
running build_py
creating build
creating build\lib
creating build\lib\gurobipy
copying python36\lib\gurobipy\__init__.py -> build\lib\gurobipy
copying python36\lib\gurobipy\gurobipy.pyd -> build\lib\gurobipy
running install_lib
running install_egg_info
Removing C:\ProgramData\Anaconda3\Lib\site-packages\gurobipy-8.1.0-py3.6.egg-inf
o
Writing C:\ProgramData\Anaconda3\Lib\site-packages\gurobipy-8.1.0-py3.6.egg-info

removing C:\gurobi810\win64\build

[Hit ENTER to exit]

I don't get an error, but c:\Python27 is still the default directory when I click the pysetup.bat again.

This tells me that it is indeed a path environment error.
Reply all
Reply to author
Forward
0 new messages