amspython: Python Stack#

Tip

For copy-pasteable AMS Python workflows, see Python Examples.

General#

The Amsterdam Modeling Suite includes a curated Python stack containing the SCM Python packages and their dependencies. The Python version and distribution depend on the AMS release:

AMS version

Python version

Python distribution

AMS2027.1 -

3.13.17

CPython

AMS2023.1 - AMS2026

3.8.12

Enthought

AMS2020.1 - AMS2022.1

3.6.9

Enthought

For the legacy Enthought stack and its per-user virtual environments, see the AMS2026.1 Python stack documentation. The instructions below apply to AMS2027.1 and later.

Use amspython to run scripts with the bundled packages:

"$AMSBIN/amspython" script.py

Open a terminal with the AMS environment variables set, as described in Getting Started. You do not need to install Python or activate a virtual environment first. The bundled environment is separate from other Python installations on your computer.

Python packages available in amspython#

The Python stack comes pre-installed with, for example:

  • PLAMS: Python library for running and analyzing AMS calculations

  • ParAMS: Python tools for fitting force-field and other model parameters to reference data

  • pyCRS: Python library for running and analyzing COSMO-RS calculations

  • inputs: Python library for preparing AMS input files

  • SCM Base Library: Python library for chemical structures, units, and parsing AMS input files

  • AKFReader: Python library for reading and parsing the AMS KF output files

  • ASE: Use external calculators with AMS or AMS as an ASE calculator

  • pyZacros: Python library for Zacros Kinetic Monte Carlo simulations

  • FlexMD: advanced Python-based molecular dynamics and QM/MM

  • AuToGraFS: Python tools for MOFs, zeolites, and COFs

  • NumPy, SciPy, pandas, and Matplotlib for numerical work, data analysis, and plotting

  • RDKit and pymatgen for molecular and materials modeling

  • JupyterLab for interactive work

List the packages and versions in your installation with:

"$AMSBIN/amspython" -m pip list

The compliance report in $AMSHOME/third-party-software.txt also lists third-party software shipped with AMS, including the Python packages, with their versions and license notices.

Supported optional components, including machine-learning backends, are installed with the AMS package manager. Their Python environments are separate from amspython. For details, see the ML Potential installation guide.

Some external packages provide additional workflows for AMS. These packages are developed independently of SCM and are not included in amspython. Follow their own installation instructions in a separate Python environment:

  • PyADF: Python tools for automating multiscale simulation workflows

  • tcutility: Python utilities for programs developed by the TheoCheM group

Using SCM Python packages in another Python environment#

Important

The bundled amspython environment is maintained as part of AMS. Do not install, upgrade, or uninstall packages directly in it with pip, uv, or another package manager. Use a separate environment for additional packages or different dependency versions.

AMS includes uv for creating a separate Python environment and installing the SCM Python packages and any additional dependencies you need. The separately distributed SCM packages support the following Python versions:

AMS version

Supported Python versions

AMS2027.1 -

3.10 - 3.15

Choose a version supported by your other dependencies as well. The example below uses Python 3.14. Start by creating a project:

"$AMSBIN/uv/uv" init --python 3.14 my-project
cd my-project

SCM provides its Python packages through a package index. Downloading these packages requires the SCM username and password supplied to AMS customers and free-trial users.

Add the following to the project’s pyproject.toml to use the SCM index for scm-base and plams. These entries select the download source; they do not yet add the packages to the project’s dependencies:

[tool.uv.sources]
scm-base = { index = "scm" }
plams = { index = "scm" }

[[tool.uv.index]]
name = "scm"
url = "https://downloads.scm.com/Downloads/packages/uv/channels/2026.1/simple/"
explicit = true

The explicit = true setting limits this index to packages listed in [tool.uv.sources]. Other dependencies are downloaded from PyPI. This follows uv’s package index configuration.

Log in once, entering your SCM username and password when prompted:

"$AMSBIN/uv/uv" auth login downloads.scm.com

uv stores the credentials separately from your project and reuses them for subsequent downloads; see uv authentication.

Now add the packages to [project].dependencies and install them with uv add:

"$AMSBIN/uv/uv" add scm-base plams

For a larger selection of SCM packages and their index configuration, see the Amsterdam Modeling PySuite instructions.

Add any other packages to this project and run scripts with its interpreter:

"$AMSBIN/uv/uv" add name_of_package
"$AMSBIN/uv/uv" run python script.py

These commands use the project’s environment. Running amspython continues to use the bundled AMS environment.

Using your own modules with amspython#

To import your own Python source files from amspython, add their directory to SCM_PYTHONPATH. For example, if my_module.py is in $HOME/my-python-modules:

export SCM_PYTHONPATH="$HOME/my-python-modules"
"$AMSBIN/amspython" -c "import my_module"

Separate multiple directories with : on macOS and Linux, or ; on Windows. These modules must be compatible with the bundled Python version and packages. Directories in SCM_PYTHONPATH take precedence over bundled packages, so avoid using it to replace their dependencies.

When you run amspython, its launcher clears inherited PYTHONPATH and PYTHONHOME settings, then uses SCM_PYTHONPATH as PYTHONPATH. SCM_PYTHONPATH does not affect python in a separate environment.

Using amspython in an IDE#

You can use the bundled Python interpreter in VS Code, PyCharm, or another IDE. Choose an existing interpreter in the IDE’s Python settings and browse to:

  • macOS and Linux: $AMSBIN/python_stack/amspython/.venv/bin/python

  • Windows: $AMSBIN/python_stack/amspython/.venv/Scripts/python.exe

Use the full filesystem path in the file picker, replacing $AMSBIN with your installation’s bin directory. You can print the interpreter path in an AMS terminal with:

"$AMSBIN/amspython" -c "import sys; print(sys.executable)"

Start the IDE from a terminal with the AMS environment set so that scripts can find AMS programs. The interpreter already contains the bundled packages. Select it as an existing environment rather than creating or modifying one.

In VS Code, install Microsoft’s Python extension, open the Command Palette (Cmd+Shift+P on macOS, Ctrl+Shift+P on Windows and Linux), and run Python: Select Interpreter. Choose Enter interpreter path… to browse to the executable above. If your version only lists discovered environments, add the environment’s .venv directory to python-envs.globalSearchPaths in Settings and select it again; see VS Code’s environment discovery guide.

If debugging still uses a different Python interpreter, set it explicitly in the python field of your .vscode/launch.json configuration, using the full interpreter path printed above. See VS Code’s Python debugger configuration.

Most Python scripting can use this interpreter directly. Some integrations need extra settings supplied by the amspython launcher, such as the bundled PLUMED library. For notebooks, connecting to a Jupyter server started with amspython also applies those settings.

Running JupyterLab (Jupyter Notebooks)#

To get started, we recommend following the GUI tutorial Run Jobs with Jupyter Notebooks.

JupyterLab is included in the Python stack. Start it from SCM → JupyterLab in AMSjobs, or from the command line:

"$AMSBIN/amspython" -m jupyterlab

This will open JupyterLab in your web browser.

To create a new notebook, click the blue plus (+) button at the top left and select Notebook → Python 3 (ipykernel).

Run Jupyter notebooks through VS Code#

Connect VS Code to a Jupyter server started with amspython:

  • Install Microsoft’s Python and Jupyter extensions in VS Code, then open an .ipynb file in the notebook editor.

  • Start JupyterLab with "$AMSBIN/amspython" -m jupyterlab. Copy the server URL printed in the terminal, including its token. You can close the browser window, but keep the server running.

  • Click Select Kernel (or the current kernel name) at the notebook’s upper right. You can also run Notebook: Select Notebook Kernel from the Command Palette. Choose Select Another Kernel… → Existing Jupyter Server, then Enter the URL of the running Jupyter server and paste the URL. Select the Python kernel offered by that server.

These options belong to the notebook kernel picker, rather than the Python interpreter picker. If they are missing, check that the Jupyter extension is enabled in the VS Code window where you opened the notebook.

See also the VS Code kernel selection guide.

Execute a notebook from the command-line#

To execute a notebook without opening JupyterLab, use the bundled helper:

"$AMSBIN/amspython" "$AMSBIN/run_notebook_inplace.py" notebook.ipynb

This executes the cells in order and writes the outputs back into the same notebook. Make a copy first if you want to preserve the original. The helper does not print cell output while it runs. Before running on a compute cluster, remove or disable any cells that open GUI windows.

You can also submit notebooks through AMSjobs; see the JupyterLab tutorial.

Jupyter frequently asked questions#

Select kernel#

When opening a notebook, you may be asked to select a kernel:

../_images/select_kernel_fd378841.png

If you are unsure which kernel to select, create a new notebook in JupyterLab and check its kernel name in the top right:

../_images/correct_kernel_a3c29bdf.png

Jupyter may also detect kernels unrelated to AMS, installed by you or another program.

VS Code asks to install ipykernel#

If you selected a local interpreter for a notebook and VS Code asks you to install ipykernel, check the interpreter path in View → Output → Jupyter. The bundled amspython/.venv already includes ipykernel; the base interpreter under $AMSBIN/python_stack/python does not.

Check the bundled environment in an AMS terminal on macOS or Linux with:

"$AMSBIN/python_stack/amspython/.venv/bin/python" -c "import sys, ipykernel; print(sys.executable); print(ipykernel.__version__)"

On Windows, run the same check using $AMSBIN/python_stack/amspython/.venv/Scripts/python.exe.

If this succeeds, ensure that VS Code selected the path inside amspython/.venv, rather than the base interpreter. If VS Code still reports a missing kernel package, use the Jupyter server connection described above. Do not install packages into the bundled environment in response to the prompt.

Notebook is not trusted#

Jupyter may mark a downloaded notebook as untrusted. This restricts existing HTML and JavaScript outputs; it does not prevent you from running the cells. Running the cells again creates trusted outputs.

If you trust the notebook’s source, you can also mark it as trusted explicitly:

"$AMSBIN/amspython" -m jupyter trust notebook.ipynb

See Jupyter’s notebook trust model.

Useful commands#

  • Start a Python shell:

    "$AMSBIN/amspython"
    
  • Check the Python version:

    "$AMSBIN/amspython" --version
    
  • List installed packages:

    "$AMSBIN/amspython" -m pip list
    
  • Find out the location of an installed package (e.g. numpy):

    "$AMSBIN/amspython" -c 'import numpy; print(numpy.__file__)'
    
  • Find out which Python interpreter is launched by amspython:

    "$AMSBIN/amspython" -c 'import sys; print(sys.executable)'