Why does running a Psi script through Python give a SyntaxError?

I am new to psi4, and I have question on why the following piece of code will give “invalid syntax” error.

memory 600 mb

molecule h2o {
  O 
  H 1 0.96
  H 1 0.96 2 104.5
}

set basis cc-pVDZ
energy('scf')

The syntax errors appear after “600” and “h2o”. The sample is from the psi4 website, so it is very confusing. I am pretty sure the psi4 is installed properly, as the following code can be run

import psi4 
h2 = psi4.geometry("""
	units au
H 
H 1 1.4010000
""")

basis = 'cc-pvdz'

E , wfn = psi4.energy( 'scf/' + basis , return_wfn = True )
psi4.set_options({'reference': 'rhf'})
psi4.optimize( 'scf/' + basis , molecule=h2 )


psi4.fcidump(wfn)

Many thanks in advance for the help!

Please read our best practices on posting topics and edit your post accordingly. In particular, you need to enclose your input file in backticks for this question. For debugging syntax errors, we need to know exactly what input file you attempted to run.

Thank you for the suggestions. That is in fact one question I had as well, which is what is input file. I don’t think I have specified any input file here. All the things for the code has been posted, and the error messages are pretty short, which said there are syntax errors in those two positions. Please let me know if this is clear.

Thank you!

Before I explain what an input file is, I need to ask:
How did you send your “code” to the computer? Did you open a Python interpreter and type in the lines that you posted here?

Hi jmisiewicz,

I use Sublime, and I just type in these codes in sublime and run it, as the usual Python script. I attached the screen shot below.

Thanks for the help!

I’ve edited your question to be more consistent with the guidelines I posted earlier.

Psi4 has been trying to serve computational chemists long before OpenFermion and related projects. For computational chemists, the typical workflow is running an executable. The executable will read and parse a structured file (the input file) instructing the executable on what computations to perform. The first piece of “code” you posted is one of these structured files. This is not a valid Python code, and it is expected to give a SyntaxError if you try to run it as one, because it is not intended to be valid Python syntax. If you want to run “code” written like that, you need to run Psi4 as an executable rather than as a Python script.

The second “code” is a Python script and can be executed as any other Python script.

I agree the first code is not a valid python code, and that is why it does not run. I will read the documentation on how to run Psi4 as an executable. Thanks!