rwl / PYPOWER

Port of MATPOWER to Python
http://rwl.github.io/PYPOWER/api/
Other
329 stars 110 forks source link

Error regarding importing a new casefile #54

Closed aaesmat closed 5 years ago

aaesmat commented 5 years ago

Hey, Sorry if it is a trivial question (I am new to pypower). I am running the following code:

from pypower.api import mygrid,ppoption, runpf, runopf, printpf ppc = mygrid()

Where "mygrid" is my case file, which is in the same format as all other case files. However, I receive the following error:

Traceback (most recent call last): File "C:/Users/ayman/PycharmProjects/Project1/RandomTest.py", line 2, in from pypower.api import mygrid,ppoption, runpf, runopf, printpf ImportError: cannot import name mygrid

I tried renaming one of the already case files (ex: case14) to "mygrid" to make sure it is the correct format, but I also received the same error. It seems that I cannot call any case file other than the ones that come with the pypower.

Am I doing something wrong ? Is there a fix for that ? I need to use my own grid with my own parameters.

Thanks.

rwl commented 5 years ago

I think the problem might be that your case file is not on your PYTHONPATH. You should be able to run:

import mygrid ppc = mygrid.mygrid()

or

from mygrid import mygrid ppc = mygrid()

assuming that the function in our module is called "mygrid". If this returns an ImportError your need to add your module to the PYTHONPATH. Doing so is common in Python programming and should be well documented online.

On Wed, 6 Mar 2019 at 09:23, Ayman Esmat notifications@github.com wrote:

Hey, Sorry if it is a trivial question (I am new to pypower). I am running the following code:

from pypower.api import mygrid,ppoption, runpf, runopf, printpf ppc = mygrid()

Where "mygrid" is my case file, which is in the same format as all other case files. However, I receive the following error:

Traceback (most recent call last): File "C:/Users/ayman/PycharmProjects/Project1/RandomTest.py", line 2, in from pypower.api import mygrid,ppoption, runpf, runopf, printpf ImportError: cannot import name mygrid

I tried renaming one of the already case files (ex: case14) to "mygrid" to make sure it is the correct format, but I also received the same error. It seems that I cannot call any case file other than the ones that come with the pypower.

Am I doing something wrong ? Is there a fix for that ? I need to use my own grid with my own parameters.

Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rwl/PYPOWER/issues/54, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAmLbj-V7W4SIq4f1ZmFFVE9RrS-6VQks5vT3sBgaJpZM4bgTwN .

aaesmat commented 5 years ago

Thank you for the clarification! 👍
I see the problem now.