Skip to content
Lori A. Burns edited this page Apr 28, 2017 · 5 revisions

STOP! This page is out-of-date and is superseded by the docs

Python Interpreter and Libraries

In Psi4, Python allows the core compiled C++ code to be flexibly accessed for manipulation and extension in an interpreted language.

Examples

  • #####Rely on Auto-Detection

    setup
    
  • #####Link Against Specific Python

    setup --python=/path/to/python/interpreter
    
  • #####Link Against Conda Psi4dependencies Package

    setup --conda-dependdir=$CONDA/envs/p4dep
    

Imposing your will upon CMake

  • #####Relevant setup Options:

    --python = PYTHON     The Python interpreter (development version) to use.
                        CMake will detect one automatically, if omitted.
                        (default: None)
    
  • #####Relevant cmake Options:

    -DPYTHON_INTERPRETER=PYTHON     - path to the Python interpreter
    

Notes

  • Dependency Status: Required

  • Allowed versions: 2.7, 3.3, 3.4 (test with python --version)

  • ##### What is the Python 3 status of Psi4

    The code has been adapted for compatibility with both Python 2 and 3, but the latter isn't tested much. Python 3 may well be broken at any given time. Let the developers know, and we'll fix it.

  • CMake Python detection is shaky on the key point of finding a matching Python interpreter and library. Due to particular problems with this in CMake 2.8, we require CMake 3.0 as minimum version. Even the latest CMake 3.1.0 release candidate can lead to unmatching interpreter/libraries found. So ConfigPython.cmake includes some macros that explicitly force searches for libraries and headers in directories suggested by the interpreter.

  • Errors can occur at runtime if the active python interpreter in your shell does not correspond with the python library Psi4 is compiled against. Compare the interpreter (which python) and the runtime library (ldd psi4), and adjust your shell if they don't look to match.

  • In addition to the Python interpreter (e.g., python), Psi4 requires the Python developer libraries (e.g., libpython.so). cmake will fail if these aren't present, or look for the python-config corresponding to your interpreter (e.g., python2.6-config if your interpreter is python2.6). If not found, you may need to install additional OS packages.

  • Packages to install for specific OS or package managers:

    • Fedora python-devel
    • Ubuntu python-dev
    • Conda python=2.7
  • Troubleshooting