-1

尝试使用python调用psse。但是导入 dyntools 有问题。

from __future__ import division

import os, sys, math, csv, time
PSSPY_location = r'C:\Program Files (x86)\PTI\PSSE34\PSSPY27'
PSSE_location = r'C:\Program Files (x86)\PTI\PSSE34\PSSBIN'
sys.path.append(PSSPY_location)
os.environ['PATH'] += ';' + PSSPY_location
os.environ['PATH'] += ';' + PSSE_location

import socket
import struct
import numpy, copy

import initialize_mute as mt    # mute all psse outputs
# import psse34
import dyntools
import psspy
import redirect
import dyntools
  File ".\dyntools.py", line 51, in <module>
ImportError: No module named pssevrsn

进程以退出代码 1 结束

4

2 回答 2

0

PSSE 手册表明您需要在脚本中定义PSSPY_locationPSSE_location,但这里有另一个选项可以告诉 Python 您的 PSSE 安装在哪里。

在Python 安装目录中创建一个扩展名为.pth,(例如__psspy__.pth)的文件。site-packages这可能C:\Python27\Lib\site-packages\__psspy.pth__适合您。该文件的内容将只是C:\Program Files (x86)\PTI\PSSE34\PSSPY27. 每当你启动你的 python 解释器时,它会.pth在这个目录中查找文件中包含的路径,并在你进行import语句时在这些位置查找 python 模块。

那么你的脚本应该如下:

import psse34
import psspy
import dyntools
import redirect

如果您仍然无法导入,请dyntools确保它在应有的位置,即C:\Program Files (x86)\PTI\PSSE34\PSSPY27\dyntools.pyc

对于 PSSE v34,请记住始终import psse34在导入任何其他与 PSSE 相关的 python 模块之前执行此操作。

于 2019-06-27T15:47:27.913 回答
0

我将 pssevrsn 从 Bin 目录复制到 Python27 目录,它没有对我产生错误。我希望它适用于

于 2019-12-12T13:45:26.357 回答