Tests fail with python3

Dear all

I recently installed Psi4 from source on my laptop and went with python 3.5 because CMake found it first.

When running the test full test suit, some of the tests fail:

The following tests FAILED:
269 - psimrcc-ccsd_t-2 (Failed)
345 - psi4numpy-cphf (Failed)
347 - psi4numpy-rhf (Failed)
349 - python-energy (Failed)
350 - python-curve (Failed)
351 - python-pubchem (Failed)
352 - python-mints9 (Failed)
353 - python-mints2 (Failed)
354 - python-cc54 (Failed)
355 - json-energy (Failed)
356 - json-gradient (Failed)
Errors while running CTest

The first test seems to be a known problem, but the others seem to occur because CTest somehow calls python2. Here is an example output from LastTest.log

Start testing: Jul 05 17:26 CEST

349/356 Testing: python-energy
349/356 Test: python-energy
Command: “/usr/bin/python3.5” “/home/rolf/psi4/tests/runtest.py” “/home/rolf/psi4/tests/python/energy/input.dat” “/home/rolf/psi4/objdir/testresults.log” “false” “/home/rolf/psi4” “false” “/home/rolf/psi4/objdir/tests/python/python-energy/output.dat” “/home/rolf/psi4/objdir/stage/usr/local/psi4/bin/psi4” “/home/rolf/psi4/objdir/stage/usr/local/psi4/share/psi4” “/home/rolf/psi4/objdir/stage/usr/local/psi4/lib/”
Directory: /home/rolf/psi4/objdir/tests/python/python-energy
“python-energy” start time: Jul 05 17:26 CEST
Output:

Traceback (most recent call last):
File “/home/rolf/psi4/tests/python/energy/input.py”, line 1, in
import psi4
File “/home/rolf/psi4/objdir/stage/usr/local/psi4/lib/psi4/init.py”, line 60, in
raise ImportError("{0}".format(err))
ImportError: /home/rolf/psi4/objdir/stage/usr/local/psi4/lib/psi4/core.so: undefined symbol: _Py_FalseStruct
Exit Status: infile ( 1 ); autotest ( None ); sowreap ( None ); overall ( 1 )

Test time = 0.05 sec

Test Failed.
“python-energy” end time: Jul 05 17:26 CEST
“python-energy” time elapsed: 00:00:00

I’m using Ubuntu 17.04 and the native python 3.5. As far as I can tell from the command, it points to the correct interpreter.
This error did not occur when compiling with python 2.

best
Rolf

So all tests except for (python-, json-, psi4numpy-) run in Psithon mode – the normal bin/psi4 input.in. bin/psi4 is a light wrapper that essentially calls Psi4 as a python module via import psi4. Because it’s an executable, we can put a shebang at the top so that it always calls the python that CMake found and which psi4 was compiled against, even if its not in your path. Thus, most of your test cases are fine. The (python-, json-, psi4numpy-) tests run in PsiAPI mode – called via python input.py. That “python” is the one in your path, which is probably not the one CMake found. Because it’s not the same version of python that psi4 was compiled against, those tests fail. So add the path to the python found in <objdir>/stage/<TAB>/<TAB>/.../bin/psi4 to your :envvar:PATH, and all should be well.

I tried that, but I get the same error.
I also tried alias python=/usr/bin/python3.5, the correct interpreter, but still no difference.

This only seems to be a problem with the tests, not Psi4 itself as going into python3.5 and importing psi4 works fine.