Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Import custom

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.

Import custom

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.

Import customcustom Python file.

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.

Import custom Python file.custom

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.

Import customcustom Python file.

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.