- Posts: 8
Python 3.4 wrapper for SDK
- mikeroberts
- Topic Author
Less
More
22 Nov 2016 21:48 #4957
by mikeroberts
Python 3.4 wrapper for SDK was created by mikeroberts
Hi,
I'm trying to access the SAM SDK via python 3.4 script running on 64bit windows
I have downloaded the latest SDK version and also the pysamsdk from Stephen Schneider github.com/sjschneider/py3samsdk as suggested in this thread:https://sam.nrel.gov/node/69256
I have added ..SAM/languages/python and ..SAM/win64 and ..pysamsdk-master/pysamsdkto the python path, and have imported sscapi
but I am still getting this error message: OSError: SAM SSC library was not found on the Python Path or in this folder
at this line:
ssc = sscapi.PySSC()
Have I missed some files/folders that need to be included in the path?
I'm trying to access the SAM SDK via python 3.4 script running on 64bit windows
I have downloaded the latest SDK version and also the pysamsdk from Stephen Schneider github.com/sjschneider/py3samsdk as suggested in this thread:https://sam.nrel.gov/node/69256
I have added ..SAM/languages/python and ..SAM/win64 and ..pysamsdk-master/pysamsdkto the python path, and have imported sscapi
but I am still getting this error message: OSError: SAM SSC library was not found on the Python Path or in this folder
at this line:
ssc = sscapi.PySSC()
Have I missed some files/folders that need to be included in the path?
Please Log in or Create an account to join the conversation.
- pgilman
Less
More
- Posts: 5447
28 Nov 2016 10:52 #4958
by pgilman
Replied by pgilman on topic Python 3.4 wrapper for SDK
Dear Mike,
You may want to ask your question as a reply to Stephen Schneider's post so that he is notified of your interest in his code.
Did you also include the 64-bit version of ssc.dll in the folder along with the other Python wrapper files?
If you are new to the SDK, you may want to consider using SAM's code generator to set up your first Python script. The code generator creates a folder with all of the files you need to run SSC from Python. Once you get that running, you can experiment with Stephen's Python wrapper.
To use the code generator, start SAM, and create a case for the system you want to model in the SDK. Then, from the Case menu (click the carrot on the Case tab at the top of the SAM main window), click Generate code and choose a language.
Best regards,
Paul.
You may want to ask your question as a reply to Stephen Schneider's post so that he is notified of your interest in his code.
Did you also include the 64-bit version of ssc.dll in the folder along with the other Python wrapper files?
If you are new to the SDK, you may want to consider using SAM's code generator to set up your first Python script. The code generator creates a folder with all of the files you need to run SSC from Python. Once you get that running, you can experiment with Stephen's Python wrapper.
To use the code generator, start SAM, and create a case for the system you want to model in the SDK. Then, from the Case menu (click the carrot on the Case tab at the top of the SAM main window), click Generate code and choose a language.
Best regards,
Paul.
Please Log in or Create an account to join the conversation.
- solarjoe
Less
More
- Posts: 73
17 Jan 2017 04:08 #4959
by solarjoe
Replied by solarjoe on topic Python 3.4 wrapper for SDK
This has been a while ago, but here are some solutions.
For use with the version that comes with sam-sdk, add this at the top of your script:
SDK_PATH = 'C:/SAM/sam-sdk-2016-3-14-r3/win64'
os.environ = os.pathsep.join([os.path.normpath(SDK_PATH),
Or this:
SDK_PATH = 'C:/SAM/sam-sdk-2016-3-14-r3/win64'
os.chdir(SDK_PATH)
If you are using Stephen Schneider's
For use with the version that comes with sam-sdk, add this at the top of your script:
SDK_PATH = 'C:/SAM/sam-sdk-2016-3-14-r3/win64'
os.environ = os.pathsep.join([os.path.normpath(SDK_PATH),
Or this:
SDK_PATH = 'C:/SAM/sam-sdk-2016-3-14-r3/win64'
os.chdir(SDK_PATH)
If you are using Stephen Schneider's
Please Log in or Create an account to join the conversation.
- Tom Hardy
Less
More
- Posts: 13
06 Feb 2017 04:25 #4960
by Tom Hardy
Replied by Tom Hardy on topic Python 3.4 wrapper for SDK
Hello Paul,
I am running SAM 2017.1.17 in a Mac and would like to generate SAM's code for a Python script. I have seen you have mentioned several times two possible ways from SAM's interface:
- Shift+F5
- Case menu / Generate code
For a Photovoltaic (detailed) system, I have tried Shift+F5 and it's not working, maybe it only works for Windows. Would you know the shortcut for Mac?
I have also gone to Case menu, but there is only: Simulate (F5), Generate report (F6), Clear all results,.... apparently there isn't the option of "Generate code"...
Any insights?
Thanks!
I am running SAM 2017.1.17 in a Mac and would like to generate SAM's code for a Python script. I have seen you have mentioned several times two possible ways from SAM's interface:
- Shift+F5
- Case menu / Generate code
For a Photovoltaic (detailed) system, I have tried Shift+F5 and it's not working, maybe it only works for Windows. Would you know the shortcut for Mac?
I have also gone to Case menu, but there is only: Simulate (F5), Generate report (F6), Clear all results,.... apparently there isn't the option of "Generate code"...
Any insights?
Thanks!
Please Log in or Create an account to join the conversation.
- pgilman
Less
More
- Posts: 5447
08 Feb 2017 14:42 #4961
by pgilman
Replied by pgilman on topic Python 3.4 wrapper for SDK
Dear Tom,
I finally had a chance to test this on my Mac, and the generate code features seems to work fine for me. Here are some things to check:
1. Make sure you are using SAM 2017.1.17 and not inadvertently running an older version. The version number should appear in title bar at the top of the SAM window.
2. To use the shortcut key, you may need to press Shift+fn+F5. The "fn" button on my Macbook Pro is at the bottom left of the keyboard.
3. To show the case menu, click the small arrow or carrot that looks something like a small 'v' just to the right of the case name on the tab at the top of the SAM window. The case name may be the default "untitled" if you did not change it.
Best regards,
Paul.
I finally had a chance to test this on my Mac, and the generate code features seems to work fine for me. Here are some things to check:
1. Make sure you are using SAM 2017.1.17 and not inadvertently running an older version. The version number should appear in title bar at the top of the SAM window.
2. To use the shortcut key, you may need to press Shift+fn+F5. The "fn" button on my Macbook Pro is at the bottom left of the keyboard.
3. To show the case menu, click the small arrow or carrot that looks something like a small 'v' just to the right of the case name on the tab at the top of the SAM window. The case name may be the default "untitled" if you did not change it.
Best regards,
Paul.
Please Log in or Create an account to join the conversation.
- sfrye
Less
More
- Posts: 1
07 May 2018 16:44 #4962
by sfrye
Replied by sfrye on topic Python 3.4 wrapper for SDK
I am still having trouble getting this into Python. Can anyone assist?
from py3samsdk import PySSC
ssc_lib = 'C:\Users\sfrye\2017.9.5.SAM\x64\ssc.dll' # path to SAM SSC Library
ssc = PySSC(ssc_lib)
and here's the error:
File "", line 2
ssc_lib = 'C:\Users\sfrye\2017.9.5.SAM\x64\ssc.dll' # path to SAM SSC Library
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
from py3samsdk import PySSC
ssc_lib = 'C:\Users\sfrye\2017.9.5.SAM\x64\ssc.dll' # path to SAM SSC Library
ssc = PySSC(ssc_lib)
and here's the error:
File "", line 2
ssc_lib = 'C:\Users\sfrye\2017.9.5.SAM\x64\ssc.dll' # path to SAM SSC Library
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Please Log in or Create an account to join the conversation.
Moderators: pgilman