Python 3.4 wrapper for SDK

5 posts / 0 new
Last post
mikeroberts
Python 3.4 wrapper for SDK

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 https://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?

Paul Gilman

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.

solarjoe

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['PATH'] = 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 py3samsdk
you can do what he mentions on the github page:

Find the system library (ssc.dylib, ssc.so, ssc.dll) and copy to your Python path

from py3samsdk import PySSC
ssc_lib = './ssc.dylib' # path to SAM SSC Library
ssc = PySSC(ssc_lib)

Or initialize the module with the correct path:

SDK_PATH = 'C:/SAM/sam-sdk-2016-3-14-r3/win64/'
PySSC(ssc_lib)

Tom Hardy

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!

Paul Gilman

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.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer