Forum Discussion

FICO's avatar
FICO
Community Manager
9 years ago

xpress python module: has no attribute

I am trying to use xpress with python for the first time. I have installed Xpress 8.3 32 bit. I am trying to run the first example from A Practical Guide to the New Python Interface for FICO Xpress Optimizer | FICO® (http://www.fico.com/en/latest-thinking/on-demand-webinar/a-practical-guide-to-the-new-python-interface-for-fico-xpress-optimizer)

if I run:

import xpress as xp

x = xp.var(vartype = zp.integer, lb= -1, ub = 5)

Then I get the error:

AttributeError: module 'Xpress' has no attribute 'var'

I get a similar error when I try to use xp.problem

Does anyone know why this is happening?

Kind regards,

Meagan

2 Replies

  • FICO's avatar
    FICO
    Community Manager

    Hi Meagan,

    that's a weird error, since var and problem are two fundamental classes in the Xpress module. For what it's worth, a similar error happened to me a few times when there was a "xpress.py" file around with no valuable content. The effect of the "import xpress" command is that of importing all objects from xpress.py, which prevents from importing the actual module. I assume this depends very much on where you run the command. Can you check the files in the directory where you're running Python?

    Also, while we're at it: make sure you replace that zp.integer with xp.integer in the call to xp.var().

    Pietro

  • FICO's avatar
    FICO
    Community Manager

    Hi again Meagan,

    we have found recently a problem with the Python interface that might explain the behavior you are observing. We have fixed the bug and it will be gone in the next patch release.