Python Syntax Error in F-SAPT Process

When I was trying to imitate the F-SAPT example and run the, an error occured:

File “./”, line 147
def get_natoms(frags: Dict[str, Dict[str, List[int]]]) → Dict[str, int]:
SyntaxError: invalid syntax

I tried to use provided python3/python3.1/python3.10 ending up with all in vain, thus I am curious about which factor cause this problem and how to solve it.

Thanks for bringing this issue to our attention. I am looking into it to see if a bugfix is needed.

In the meantime, I noticed in the file psi4/psi4/share/psi4/fsapt/ that the function get_natoms() is never called. Could you please comment out or delete this function (lines 147-170 in psi4/psi4/share/psi4/fsapt/ and try again?

Thanks for your considering, however, deleting this function does not help

The function read_d3_fragments() will also lead to an error, like what is shown below:

def read_d3_fragments(dirname: Optional[str] = '.') -> Dict[str, Dict[str, List[int]]]:

SyntaxError: invalid syntax

I strongly suspect that there are more than one function with error

When I run the script, I don’t get syntax errors. This makes me suspect that the file is fine, but your Python version is not. The latest error you gave suggests that your Python version is too old for it to recognize type hint syntax.

The Python 3.10 version you mentioned earlier is unquestionably sufficient to run the file. Please confirm the Python version one more time.

It makes me puzzled :frowning:

(base) [kilmorph@localhost fsapt]$ python
Python 3.10.11 (main, May 16 2023, 00:28:57) [GCC 11.2.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

In the file I also set


I don’t get any syntax errors on my machine. However, the function read_d3_fragments() is also never called, and please feel free to remove this function and try again.

It looks like your Python settings request a stricter checking of the code than mine, and that’s how you get syntax errors from functions that are never called? I’m not sure.