Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Python Path...What am I doing wrong?

    Posted 10/19/11 07:48 PM

    Originally posted by: Eumpfenbach


    I have searched numerous python path websites on google and am stuck. I run Ubuntu 10.04 and ILOG 12.2.

    I start up the prompt:

    ed@ed-laptop:~$ python
    Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
    http://GCC 4.4.3 on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys
    >>> sys.path
    So the python path is set right, right?

    So if I open a new prompt and type the following, I get an error. I have mipex1.py in the ILOG path above (and /usr/lib/python2.6 just to be safe).

    ed@ed-laptop:~$ python mipex1.py
    python: can't open file 'mipex1.py': Errno 2 No such file or directory
    ed@ed-laptop:~$

    If I try and start the file this way, I also get an error:

    ed@ed-laptop:~$ python
    Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
    http://GCC 4.4.3 on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> mipex1.py
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'mipex1' is not defined
    Any help would be appreciated. I'm just starting with python and am not sure what I am doing wrong.

    Ed
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Python Path...What am I doing wrong?

    Posted 10/19/11 10:38 PM

    Originally posted by: Eumpfenbach


    I was a bit incomplete in my above post. When I type in the sys.path command it shows the python directory with the cplex folder in there. I left out the terminal output for that, but I've checked 10 times and it is there.
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Python Path...What am I doing wrong?

    Posted 10/20/11 11:54 AM

    Originally posted by: Eumpfenbach


    here's the info I left out.

    ed@ed-laptop:~$ python
    Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
    http://GCC 4.4.3 on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys
    >>> sys.path
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Python Path...What am I doing wrong?

    Posted 10/20/11 11:55 AM

    Originally posted by: Eumpfenbach


    '', '/home/ed/ILOG/CPLEX_Studio_AcademicResearch122/cplex/python/x86-64_sles10_4.1', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-packages'
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Python Path...What am I doing wrong?

    Posted 10/20/11 05:25 PM

    Originally posted by: SystemAdmin


    I'm not sure (I've used Python very little), but I think the Python path is checked only when Python is importing a module. I'm not sure the path is searched for scripts specified in the command line. Try giving the absolute path to the script in the command line.

    Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Python Path...What am I doing wrong?

    Posted 10/20/11 06:51 PM

    Originally posted by: Eumpfenbach


    Thanks for the answer.

    It definitely works if I type python /path.../myscript.py

    However, according to several websites (for example, http://www.ehow.com/how_8282375_run-python-scripts-linux.html) you should be able to just type python myscript.py

    Obviously I could run the script by just typing the path, but this really isn't my core problem. I have written matlab code to solve a cplex problem, but want to be able to use the callbacks. I am trying to use a file off the matlab file exchange called pymex that integrates python into matlab (this way I can utilize all the scripts I have written to create my matrices and vectors, pass them to python, control the cplex search, then bring them back into matlab).

    I was thinking that since I can't call python the way mentioned in the ehow page above, I thought maybe it was caused by the same problem. Not sure. Something isn't right...
    #CPLEXOptimizers
    #DecisionOptimization