[英]How to fix 'ImportError: No module named pssevrsn'
嘗試使用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 結束
PSSE 手冊指出你需要在你的腳本中定義PSSPY_location
和PSSE_location
但這里有另一個選項來告訴 Python 你的 PSSE 安裝在哪里。
在 Python 安裝的site-packages
目錄中創建一個擴展名為.pth
的文件(例如, __psspy__.pth
)。 這可能是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,請記住在導入任何其他與 PSSE 相關的 Python 模塊之前始終import psse34
。
我將 pssevrsn 從 Bin 目錄復制到 Python27 目錄,它沒有為我出錯。 我希望它適用於
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.