ampl / amplpy

Python API for AMPL

Home Page:https://amplpy.ampl.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

use . in the "from import" will result in some error, like "from .defaults import *"

scloudyy opened this issue · comments

  • python version: 3.5
  • OS: win7

Description

I fork code to my computer, and when I try to run ampl.py some error happens. I mean if I 'pip install ampl', it works well, don't worry. But it seems we can not debug it since python do not support such like "from .errorhandler import ErrorHandler", which from the ampl.py.

What I Did

$ python ampl.py

and the feedback is
"Traceback (most recent call last):
File "ampl.py", line 7, in
from .errorhandler import ErrorHandler
SystemError: Parent module '' not loaded, cannot perform relative import"

It seems like we use . in the "form import", some error will occur. In this situation, how could we develop and debug program?

In order to debug amplpy, you can build it with python setup.py build and then update it with pip install . --upgrade after each change. Since it uses absolute imports you can't execute members of the package directly. However, you can still run for example amplpy.tests with python -m amplpy.tests. In order to debug the package you can also use python -c "import amplpy; print(amplpy.__file__)" to locate the installation folder and modify the files there.

Which problem are you having with amplpy that you want to debug?