Closed lujie11111 closed 3 years ago
Hmm, I can replicate this. For some reason the pythonnet
dependency is not installed by pip, not sure why it was not included in the dependencies in the wheel on PyPI. For now you can pip install pythonnet
manually to fix this, I'll try to find out how to repackage it with the correct dependencies.
I double checked - Requirement already satisfied: pythonnet in c:\users\luj13\appdata\local\programs\python\python38\lib\site-packages (2.5.2) Requirement already satisfied: pycparser in c:\users\luj13\appdata\local\programs\python\python38\lib\site-packages (from pythonnet) (2.20)
but still showing: with PI.PIServer() as server: print(server.search)
output: <bound method PIServer.search of PIServer(\Testing)>
Could you run this snippet to see where it goes wrong? If something fails in this step the testing framework is loaded.
import os
import sys
import clr
# Get the installation directory from the environment variable or fall back
# to the Windows default installation path
PIAF_SDK = os.getenv("PIHOME", "C:\\Program Files\\PIPC")
PIAF_SDK += "\\AF\\PublicAssemblies\\4.0\\"
if not os.path.isdir(PIAF_SDK):
raise ImportError("PIAF SDK not found in %s, check installation" % PIAF_SDK)
sys.path.append(PIAF_SDK)
clr.AddReference("OSIsoft.AFSDK") # pylint: disable=no-member
from OSIsoft import AF # pylint: wrong-import-position
AF_SDK_VERSION = AF.PISystems().Version
print("OSIsoft(r) AF SDK Version: {}".format(AF_SDK_VERSION))
no fault shown up. and with - OSIsoft(r) AF SDK Version: 2.10.8.440 as results
I added
import PIconnect as PI
print(list(PI.PIServer.servers.keys()))
after your code, and shwon time out:
System.TimeoutException: The open operation did not complete within the allotted timeout of 00:04:59.9900115. The time allotted to this operation may have been a portion of a longer timeout.
Server stack trace:
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout)
at OSIsoft.AF.Support.AFProxy.Reconnect(Boolean autoPrompt, AFConnectionProtocol protocol, String host, Int32 port, String accountName,
TimeSpan timeout)
Then I have no idea why in your situation the testing framework is loaded. I would think that when you import PIconnect
in that same session it runs exactly that code as I copied and pasted it from the sourcecode for version 0.9.0. Is the environment correctly activated in the setting where you got the error?
Regarding the timeout, it appears one of the configured servers could not be reached. There is a check for this situation that was hard to test, but apparently the check handles the wrong base type of exceptions. I will fix this in the hotfix I linked to this issue.
I just pushed a new version to PyPI, could you please update and try if the error is now gone?
Hi Hugo, the 0.9.1 version works!! Thank you so much!!
Hey @Hugovdberg - I am not sure if this is the right place for the question, but is PIconnect
expected to work on a Red Hat OS?
Bug report
Description
PIconnect
does not load the SDK correctly, but uses the Testing framework instead.Steps to reproduce the behavior:
with PI.PIServer() as server: print(server.server_name)