Python SDK
The Python SDK can be downloaded from the Customer Download page of seeq.com as part of the Seeq Server SDK download. It is included as an egg file in the python
subfolder and is also found in the Seeq Server program folder within the sdk
subfolder. To import the egg and get predictive text within an IDE you have two choices: 1) extract the contents of the egg into your working directory; 2) import the egg directly by adding it to your local path.
Extracting contents. Python eggs are zip files containing the source code plus some additional information. To extract the modules from the egg you can:
change the file extension from .egg to .zip
extracting the zip file; and
copy the resulting seeq_sdk folder to your Python project folder. You can now import using
import seeq_sdk
Direct import. Python egg files can be directly imported from the interpreter, but they must be added to the path to be detected. There are a few ways to do this.
The simplest way is to move the egg into your working directory and add it to the local
path
:Simple Import
PYimport sys sys.path.append('./seeq_sdk-0.40.02-py2.7.egg') # the file name might be slightly different depending on your version import seeq_sdk
If you want to specify a minimum version, which is especially important if there was a recent major upgrade, place the egg file in your working directory and use
require
to find it and add it to your path:Version Enforcement
PYimport sys from pkg_resources import require require("seeq_sdk==0.40.02") # you can use any comparitor you like, e.g., "seeq_sdk>=0.40.02" import seeq_sdk
If you are working directly on a server and know where the egg is kept (e.g.,
c:/program files/seeq server/sdk/python/....egg
) you can add that location to your path and import the latest one directly from there:Added From Seeq
PYimport sys import os sdk_path = 'c:/program files/seeq server/sdk/python' egg = os.listdir(sdk_path)[0] sys.path.append(os.path.join(sdk_path,egg)) import seeq_sdk
Some IDEs (like PyCharm and Spyder) allow you to specify a startup script for the IDE and/or any virtual environments you may have. You can add the path to the Seeq version of the sdk to that script and import directly every time.
Python SDK Quick Start Using PyCharm
Full details of getting started in the free, open-source PyCharm IDE are available in the Python SDK Quick Start using PyCharm.
Fixing SSL Issues When Connecting to Seeq Using the Python SDK
Ostrich Yoga
If you're having trouble with SSL, a short-term fix is to skip the SSL verification step until certificate issues can be resolved. To do so, just add a line to your script that sets verify_ssl
to False on the Configuration object:
import seeq_sdk as sdk
...
sdk.Configuration().verify_ssl = False
...
(calls to APIs)
Setting properties on Configuration
should be done prior to making any calls to APIs but can be done after instantiating an ApiClient. To solve the SSL issue, you may need to update the root certificates in your version of certifi (you should also make sure you are using the latest versions of Python 2, urllib3, and certifi). Details of adding new Certificate Authorities (CAs) to the Python certifi package are available in the next section.
Secure Access
To actually fix the connectivity issue, you will need to ensure that all the i's are dotted and t's crossed with the SSL verification. One common problem is missing root certificates; Python scripts typically rely on the certifi package to manage SSL verification, and its set of Certificate Authority (CA) certificates does not always have the root certificates for all CAs. Fortunately, we can use web browsers to get information about the certificate used to certify our site, and we can use that information to update the certifi package's list of root certificates.
Before trying the steps below, first make sure you have the latest versions of Python 2 (as of this writing, Python 2.7.15) and the pip packages urllib3, and certifi. The following description is based on the use of Chrome, but other browsers will provide similar functionality.
To fix SSL issues derived from a missing root certificate, try these steps:
Navigate to Seeq Workbench in your browser. In Chrome, you will see a lock icon and the word "Secure" in front of the Omnibar for a secure server, as shown:
Click on the "Secure" text, which will bring up a modal like this:
Click on Certificate, then switch to the Details tab and click to highlight the "Authority Information Access" field, as shown:
Copy and paste the URL shown above into a new tab, which will download a .crt file.
Download OpenSSL and install. If on Windows, make sure to add the OpenSSL\bin folder to your Path.
Using a Linux shell or a Windows Command Prompt, first verify that openssl is accessible by running the
openssl
command with no arguments, then run the following command, replacing certificate.cer with the path to the .crt file you just downloaded, including the filename:CODEopenssl x509 -inform der -in certificate.cer -out certificate.pem
This will create a file
certificate.pem
in the working directory. Open this file and copy the contents.In your code, add the following:
CODEimport seeq_sdk as sdk ... sdk.Configuration().cert_file = 'C:\\Path\\To\\certificate.pem' ... (calls to APIs)
If that doesn't work, you can try opening the
cacert.pem
file in $PYTHONPATH\Lib\site-packages\certifi and paste the text copied in the previous step. However, you run the risk that upgrading your Python library will suddenly cause SSL errors because the cacert.pem file will get overwritten.
If you are still having trouble after following these steps, feel free to contact Seeq support, although it should be noted that some issues may be better addressed by your company IT department.