TC-Python Quick Install Guide

This quick guide helps you to get a working TC-Python API installation.

There is a PDF guide included with your installation. In the Thermo-Calc menu, select Help → Manuals Folder. Then double-click to open the Software Development Kits (SDKs) folder.

Note

A license is required to run TC-Python.

Step 1: Install a Python Distribution

If you already have a Python distribution installation, version 3.5 or higher, skip this step.

These instructions are based on using the Anaconda platform for the Python distribution. Install version 3.5 or higher to be able to work with TC-Python, although it is recommended that you use the most recent version.

Install Anaconda

  1. Navigate to the Anaconda website: https://www.anaconda.com/download/.
  2. Click to choose your OS (operating system) and then click Download. Follow the instructions. It is recommended you keep all the defaults.

Step 2: Install Thermo-Calc and the TC-Python SDK

Note

TC-Python is available starting with Thermo-Calc version 2018a.

  1. Install Thermo-Calc

  2. When the installation is complete, open the TC-Python folder that includes the *.whl file needed for the next step. There is also an Examples folder with Python files you can use in the IDE to understand and work with TC-Python.

    The installation location for this API is the same as for other SDKs and based on the OS. For details, see Default Directory Locations in the Thermo-Calc Installation Guide.

Step 3: Install TC-Python

On Windows, it is recommended that you use the Python distribution prompt (i.e. Anaconda, …), especially if you have other Python installations. Do not use Virtual Environments unless you have a good reason for that.

  1. Open the command line. For example, in Anaconda on a Windows OS, go to Start→Anaconda→Anaconda Prompt.

  2. At the command line, enter the following. Make sure there are no spaces at the end of the string or in the folder name or it will not run:

    pip install <path to the TC-Python folder>/TC_Python-<version>-py3-none-any.whl
    

    For example, on a Windows OS Standalone custom installation the path to the TC-Python folder is C:\Users\Public\Documents\Thermo-Calc\2020b\SDK\TC-Python\

    Details for Mac and Linux installations are described in Default Directory Locations in the Thermo-Calc Installation Guide. Note that on Linux typically pip3 is used.

  3. Press <Enter>. When the process is completed, there is a confirmation that TC-Python is installed.

Note

If your computer is located behind a proxy-server, the default pip-command will fail with a network connection error. In that case you need to install the dependency py4j in a special configuration:

pip install -proxy user:password@proxy_ip:port py4j jproperties

See “pip install” fails with “Failed to establish a new network connection” or similar for detailed information.

Step 4: Install an IDE (Integrated Development Environment)

Any editor can be used to write the Python code, but an IDE is recommended, e.g. PyCharm. These instructions are based on the use of PyCharm.

Use of an IDE will give you access to code completion, which is of great help when you use the API as it will give you the available methods on the objects you are working with.

  1. Navigate to the PyCharm website: https://www.jetbrains.com/pycharm/download.
  2. Click to choose your OS and then click Download. You can use the Community version of PyCharm.
  3. Follow the instructions. It is recommended you keep all the defaults.

Note

For Mac installations, you also need to set some environment variables as described below in Mac OS: Setting Environment Variables.

Step 5: Open the IDE and Run a TC-Python Example

After you complete all the software installations, you are ready to open the IDE to start working with TC-Python.

It is recommended that you open one or more of the included examples to both check that the installation has worked and to start familiarizing yourself with the code.

Open the TC-Python Project in PyCharm

When you first open the TC-Python project and examples, it can take a few moments for the Pycharm IDE to index before some of the options are available.

  1. Open PyCharm and then choose File→Open. The first time you open the project you will need to navigate to the path of the TC-Python installation as done in Step 4.

    For example, on a Windows OS Standalone custom installation the path to the TC-Python folder is C:\Users\Public\Documents\Thermo-Calc\2020b\SDK\TC-Python\

    Details for Mac and Linux installations are described in the Default Directory Locations section in the Thermo-Calc Installation Guide.

  2. Click on the Examples folder and then click OK.

  3. From any subfolder:

    • Double-click to open an example file to examine the code.
    • Right-click an example and choose Run .

Fixing potential issues with the environment

In most cases you should run TC-Python within your global Python 3 interpreter and not use Virtual Environments unless you have a good reason to do so. A common problem on first usage of TC-Python is the error message “No module named tc_python”. You can resolve this and other problems with the interpreter settings as follows:

  1. Go the menu File→Settings.
  2. Navigate in the tree to Project: YourProjectName and choose Project Interpreter.
  3. Click on the settings symbol close to the Project Interpreter dropdown menu and choose Add.
  4. Now choose System Interpreter and add your existing Python 3 interpreter.
  5. Select your added interpreter and confirm.

Note

If you are not following the recommended approach and create a new project (File→New Project…), you need to consider that by default the options to choose the interpreter are hidden within the Create Project window. So click on Project Interpreter: New Virtual Environment and in most cases choose your System Interpreter instead of the default New Virtual Environment.

Note

If you really need to use a Virtual Environment, please consider the hints given in the Best Practices chapter.

Updating to a newer version

When updating to a newer version of Thermo-Calc, you always need to also install the latest version of TC-Python. It is not sufficient to run the installer of Thermo-Calc. The procedure is generally identical to Step 3:

pip install <path to the TC-Python folder>/TC_Python-<version>-py3-none-any.whl

In case of problems you may wish to uninstall the previous version of TC-Python in advance:

pip uninstall TC-Python
pip install <path to the TC-Python folder>/TC_Python-<version>-py3-none-any.whl

However, that should normally not be required. Note that on Linux usually pip3 is used.

You can check the currently installed version of TC-Python by running:

pip show TC-Python

Mac OS: Setting Environment Variables

In order to use TC-Python on Mac you need to set some environment variables.

TC20B_HOME=/Applications/Thermo-Calc-2020b.app/Contents/Resources

If you use a license server:

LSHOST=<name-of-the-license-server>

If you have a node-locked license:

LSHOST=NO-NET
LSERVRC=Users/Shared/Thermo-Calc/lservrc

In PyCharm, you can add environment variables in the configurations.

Select Run→Edit Configurations to open the Run/Debug Configurations window. Choose Templates and then Python. Enter the environment variable(s) by clicking the button to the right of the Environment Variables text field. Now the environment variables(s) will be set for each new configuration by default.

Note

Existing configurations need to be removed and recreated to obtain the environment variables in them.

The same way for configuring the environment variables can be used on other operating systems as if necessary.