Use the Wolfram Client Library for Python to start an authenticated session with the Wolfram Cloud.

Using a Wolfram Notebook...

Verify that the Wolfram Client Library for Python is installed

Open a terminal window and enter pip show wolframclient to check if the library is installed:

> pip show wolframclient
Name: wolframclient
Version: 1.1.3
Summary: A Python library with various tools to interact with the Wolfram Language and the Wolfram Cloud.
Home-page: https://www.wolfram.com/
Author: Wolfram Research
Author-email: support@wolfram.com
License: MIT
Location: \Users\person\appdata\local\programs\python\python36\lib\site-packages
Requires: pip, numpy, pytz, requests, aiohttp, oauthlib, pyzmq
Required-by: wolframwebengine

Generate a Secured Authentication Key

With the Wolfram Language, use GenerateSecuredAuthenticationKey to create unique keys to connect to a Wolfram Cloud session. You may be prompted to connect to the Wolfram Cloud first:

The output is a key object:

Use this object to get the consumer credentials as strings:

Import the following Wolfram Client Library classes

Initialize a Python cell in a notebook with :

Import the and modules:

from wolframclient.evaluation import WolframCloudSession, SecuredAuthenticationKey
  • WolframCloudSession is the main module to interact with the Wolfram Cloud.
  • WolframCloudSession typically connects to the Wolfram Public Cloud.
  • SecuredAuthenticationKey is a module storing consumer key and secret used during authentication.

Start an authenticated session

Copy and paste the previously generated consumer credentials into the associated Python function:

key = SecuredAuthenticationKey( 'T2ghIEhpISDinIw=', 'VGhhdCdzIE1ZIHNlY3JldCE=')

Initialize a cloud session using the default configuration targeting the Wolfram Public Cloud:

session = WolframCloudSession(credentials=key) session.start()

Check to verify that you are now authorized to use the Wolfram Cloud:

session.authorized()

Execute a Wolfram Language evaluation in the cloud, returning the result to Python:

session.evaluate('ImageIdentify[ First[ WebImageSearch["bird","Images",1] ] ]')

Using a Jupyter Notebook...

Verify that the Wolfram Client Library for Python is installed

Open a terminal window and enter pip show wolframclient to check if the library is installed:

> pip show wolframclient
Name: wolframclient
Version: 1.1.3
Summary: A Python library with various tools to interact with the Wolfram Language and the Wolfram Cloud.
Home-page: https://www.wolfram.com/
Author: Wolfram Research
Author-email: support@wolfram.com
License: MIT
Location: \Users\person\appdata\local\programs\python\python36\lib\site-packages
Requires: pip, numpy, pytz, requests, aiohttp, oauthlib, pyzmq
Required-by: wolframwebengine

Generate a Secured Authentication Key

With the Wolfram Language, use GenerateSecuredAuthenticationKey to create unique keys to connect to a Wolfram Cloud session. You may be prompted to connect to the Wolfram Cloud first:

The output is a key object:

Use this object to get the consumer credentials as strings:

Import the following Wolfram Client Library classes

Import the and modules:

  • WolframCloudSession is the main module to interact with the Wolfram Cloud.
  • WolframCloudSession typically connects to the Wolfram Public Cloud.
  • SecuredAuthenticationKey is a module storing consumer key and secret used during authentication.

Start an authenticated session

Copy and paste the previously generated consumer credentials into the associated Python function:

Initialize a cloud session using the default configuration targeting the Wolfram Public Cloud:

Check to verify that you are now authorized to use the Wolfram Cloud:

Execute a Wolfram Language evaluation in the cloud, returning the result to Python:

Notes

Installation instructions are provided in Install the Wolfram Client Library for Python.
You will need to ensure that the ExternalEvaluate framework is identifying the correct Python distribution on your computer. See Configure Python for External Evaluate for more details.