Trouble with making modules 'global'

pythonfm at gmail.com pythonfm at gmail.com
Wed Jun 3 23:48:20 EDT 2020


Hi,

I am struggling with making modules global for all definitions in my code.
I faced the problem with the pyomo modules but can generate the error with pandas too.

The model structure looks as follow: 

I have 3 '.py' files each of them containing definitions. The first controls inputs and outputs and starts an optimization.py file ( optimization.py). Within optimization.py I call a third .py file (model.py) that includes a series of definitions, representing mathematical equations of a optimization model.



(1) Main.py
import pandas as pd

def main_part()
... Result = optimization_def(x,y,z)
...

(2) Optimization.py
def optimization(x_l,y_l,z_l)
... O = obejctive(x_l,y_l)
...

(3) Model.py
def objctive(x_a,x_b)
...
def constraint(x_a,z_a)
....


I do not understand why pd is not known in def optimization() as well as in objctive().
I tried to make it global by adding global pd in Main.py


I would appreciate any support. Thanks in advance
Frank


More information about the Python-list mailing list