First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
I am writing lots of scripts and keep using the same functions in each script so I wanted to write a separate boilerplate Python file to store those functions and import them into my main file. This works perfectly when I am running the script outside of PSSE, but breaks when I run it in PSSE. It gives me the error NameError: global name 'psspy' is not defined
. I know this error is in the boilerplate file and not the main file because the main file runs psspy.case
successfully.
I have tried all four combinations of importing and not importing psspy in the main and boilerplate file with the code:
PSSE_LOCATION = os.path.join('C:', os.sep, 'Program Files (x86)', 'PTI', 'PSSE34', 'PSSPY27')
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + PSSE_LOCATION + ';'
import psspy
I have viewed the question "How to import a custom Python module in PSSE?" (I can't link it as I don't have enough karma), however, their problem was the module not importing correctly. The boilerplate module imports just fine, but it can't access psspy when running in PSSE.
Am I going about importing custom Python files incorrectly?
I am running PSSE 34 and Python 2.7.
2 | No.2 Revision |
I am writing lots of scripts and keep using the same functions in each script so I wanted to write a separate boilerplate Python file to store those functions and import them into my main file. This works perfectly when I am running the script outside of PSSE, but breaks when I run it in PSSE. It gives me the error NameError: global name 'psspy' is not defined
. I know this error is in the boilerplate file and not the main file because the main file runs psspy.case
successfully.
I have tried all four combinations of importing and not importing psspy in the main and boilerplate file with the code:
PSSE_LOCATION = os.path.join('C:', os.sep, 'Program Files (x86)', 'PTI', 'PSSE34', 'PSSPY27')
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + PSSE_LOCATION + ';'
import psspy
I have viewed the question "How to import a custom Python module in PSSE?" (I can't link it as I don't have enough karma), however, their problem was the module not importing correctly. The boilerplate module imports just fine, but it can't access psspy when running in PSSE.
Am I going about importing custom Python files incorrectly?
I am running PSSE 34 and Python 2.7.
3 | No.3 Revision |
I am writing lots of scripts and keep using the same functions in each script so I wanted to write a separate boilerplate Python file to store those functions and import them into my main file. This works perfectly when I am running the script outside of PSSE, but breaks when I run it in PSSE. It gives me the error NameError: global name 'psspy' is not defined
. I know this error is in the boilerplate file and not the main file because the main file runs psspy.case
successfully.
I have tried all four combinations of importing and not importing psspy in the main and boilerplate file with the code:
PSSE_LOCATION = os.path.join('C:', os.sep, 'Program Files (x86)', 'PTI', 'PSSE34', 'PSSPY27')
sys.path.append(PSSE_LOCATION)
'PSSPY27')
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + PSSE_LOCATION +
';'';'
import psspy
import psspy
I have viewed the question "How to import a custom Python module in PSSE?" (I can't link it as I don't have enough karma), however, their problem was the module not importing correctly. The boilerplate module imports just fine, but it can't access psspy when running in PSSE.
Am I going about importing custom Python files incorrectly?
I am running PSSE 34 and Python 2.7.
4 | No.4 Revision |
I am writing lots of scripts and keep using the same functions in each script so I wanted to write a separate boilerplate Python file to store those functions and import them into my main file. This works perfectly when I am running the script outside of PSSE, but breaks when I run it in PSSE. It gives me the error NameError: global name 'psspy' is not defined
. I know this error is in the boilerplate file and not the main file because the main file runs psspy.case
successfully.
I have tried all four combinations of importing and not importing psspy in the main and boilerplate file with the code:
PSSE_LOCATION = os.path.join('C:', os.sep, 'Program Files (x86)', 'PTI', 'PSSE34', 'PSSPY27')
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + PSSE_LOCATION + ';'
import psspy
I have viewed the question "How to import a custom Python module in PSSE?" (I can't link it as I don't have enough karma), however, their problem was the module not importing correctly. The boilerplate module imports just fine, but it can't access psspy when running in PSSE.
Am I going about importing custom Python files incorrectly?
I am running PSSE 34 and Python 2.7.
5 | No.5 Revision |
I am writing lots of scripts and keep using the same functions in each script so I wanted to write a separate boilerplate Python file to store those functions and import them into my main file. This works perfectly when I am running the script outside of PSSE, but breaks when I run it in PSSE. It gives me the error NameError: global name 'psspy' is not defined
. I know this error is in the boilerplate file and not the main file because the main file runs psspy.case
successfully.
I have tried all four combinations of importing and not importing psspy in the main and boilerplate file with the code:
PSSE_LOCATION = os.path.join('C:', os.sep, 'Program Files (x86)', 'PTI', 'PSSE34', 'PSSPY27')
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + PSSE_LOCATION + ';'
import psspy
I have viewed the question "How to import a custom Python module in PSSE?" (I can't link it as I don't have enough karma), however, their problem was the module not importing correctly. The boilerplate module imports just fine, but it can't access psspy when running in PSSE.
Am I going about importing custom Python files incorrectly?
I am running PSSE 34 and Python 2.7.