Unable to import Psi4 in python

Hi,

I installed psi4 through conda in linux system and the files, the specific module I wanna import is psi4_wrapper, were saved under anaconda3/lib/python3.8/site-packages.

However, while I was trying to import it in my program, it reports no module named ‘psi4’. I have no idea how to figure this out, and obviously I am using anaconda3 to run program.

Any solution to this problem?

Did you set PYTHONPATH to find the psi4 modules?
Run

psi4 --psiapi

to get the paths you need to export.

I just ran the code, and it reports:

export PATH=/usr/bin:$PATH
export PYTHONPATH=/usr/lib/x86_64-linux-gnu//:$PYTHONPATH

Does it mean the PYTHONPATH is set? Plus, if I run

psi4

in terminal, and it reports as:

'str' object is not callable; perhaps you missed a comma?
'str' object is not callable; perhaps you missed a comma?
'str' object is not callable; perhaps you missed a comma?
'str' object is not callable; perhaps you missed a comma?
"is" with a literal. Did you mean "=="?
Traceback (most recent call last):
  File "/usr/bin/psi4", line 211, in <module>
    raise KeyError("The file %s does not exist." % args["input"])
KeyError: 'The file input.dat does not exist.'

Is this supposed to be the outcome?

Not correctly. The path to the conda installation should be in there.
Do you have conda activated? edit: And switched to the psi4 environment?

Does the following work?

psi4 --test

OK, I was totally wrong about the installation. It turns out that I didn’t accomplish the installation since the package conflicts with a list of applications.

The following specifications were found to be incompatible with your system:

  • feature:/linux-64::__glibc==2.31=0
  • feature:|@/linux-64::__glibc==2.31=0
  • argon2-cffi → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • astropy → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • bitarray → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • blosc → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • bottleneck → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • brotlipy → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • bzip2 → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • c-ares → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • cairo → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • cffi → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • conda-package-handling → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • cryptography → libgcc-ng → __glibc[version=’>=2.17’]
  • curl → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • cython → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • cytoolz → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • dbus → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • expat → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • fastcache → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • fontconfig → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • freetype → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • fribidi → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • gevent → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • glib → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • gmp → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • gmpy2 → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • graphite2 → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • greenlet → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • gst-plugins-base → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • gstreamer → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • h5py → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • harfbuzz → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • hdf5 → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • icu → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • jbig → libgcc-ng[version=’>=7.2.0’] → __glibc[version=’>=2.17’]
  • jpeg → libgcc-ng[version=’>=7.2.0’] → __glibc[version=’>=2.17’]
  • kiwisolver → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • krb5 → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • lazy-object-proxy → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • lcms2 → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libarchive → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libcurl → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libedit → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libev → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libffi → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libgcc-ng → __glibc[version=’>=2.17’]
  • libgfortran-ng → __glibc[version=’>=2.17’]
  • liblief → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libllvm10 → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libpng → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libsodium → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libspatialindex → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libssh2 → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libstdcxx-ng → __glibc[version=’>=2.17’]
  • libtiff → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libtool → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libuuid → libgcc-ng[version=’>=7.2.0’] → __glibc[version=’>=2.17’]
  • libuv → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libwebp-base → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libxcb → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • libxml2 → libgcc-ng[version=’>=9.3.0’] → __glibc[version=’>=2.17’]
  • libxslt → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • llvmlite → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • lxml → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • lz4-c → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • lzo → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • markupsafe → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • matplotlib → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • matplotlib-base → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • mistune → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • mkl-service → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • mkl_fft → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • mkl_random → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • mpc → libgcc-ng[version=’>=7.2.0’] → __glibc[version=’>=2.17’]
  • mpfr → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • msgpack-python → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • ncurses → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • numba → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • numexpr → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • numpy → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • numpy-base → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • openssl → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • pango → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • patchelf → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • pcre → libgcc-ng[version=’>=7.5.0’] → __glibc[version=’>=2.17’]
  • pillow → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • pixman → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • psi4=1.4rc2 → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • psutil → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • py-lief → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • pycosat → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • pycurl → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • pyerfa → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • pyodbc → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • pyqt → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • pyrsistent → libgcc-ng[version=’>=7.5.0’] → __glibc[version=’>=2.17’]
  • pytables → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • python=3.8 → libgcc-ng[version=’>=7.5.0’] → __glibc[version=’>=2.17’]
  • pywavelets → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • pyyaml → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • pyzmq → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • qt → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • readline → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • regex → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • ruamel_yaml → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • scikit-image → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • scikit-learn → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • scipy → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • sip → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • sqlalchemy → libgcc-ng[version=’>=7.5.0’] → __glibc[version=’>=2.17’]
  • sqlite → libgcc-ng[version=’>=7.5.0’] → __glibc[version=’>=2.17’]
  • statsmodels → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • tbb → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • tifffile → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • tk → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • tornado → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • typed-ast → libgcc-ng[version=’>=7.5.0’] → __glibc[version=’>=2.17’]
  • ujson → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • unixodbc → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • wrapt → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • xz → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • yaml → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • zeromq → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • zlib → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]
  • zope.interface → libgcc-ng[version=’>=7.5.0’] → __glibc[version=’>=2.17’]
  • zstd → libgcc-ng[version=’>=7.3.0’] → __glibc[version=’>=2.17’]

Your installed version is: 2.31

Here is the final report of the installation, and I can’t figure out which of my application is wrong about the version as 2.31. Any idea about this? :joy:

psi4 is incompatible with the default anaconda environment.
Best is to create a new environment that contains psi4 with conda create -n <name>

conda create -n p4 psi4 -c psi4 # old v1.3.2
conda create -n p4dev psi4 -c psi4/label/dev # latest version

(see also here: Install v1.4.0rc2+ | Installs)

Thanks! I’m about to solve this issue by following the source installation, but it report that

CMake Error: The source directory "/home/myserver" does not appear to contain CMakeLists.txt.

How can I solve this error? By creating one CMakeList.txt file in the targetted route?

The error sounds like you are in the wrong directory.

You really want to compile psi4 yourself? This will get tricky without being experienced in code compilation.
Sure you dont want to try the conda installation once more?

So do you recommand that I run conda installation in the new environment?
And how about a new, default environment created by anaconda?

OK Thanks for your assistance, hokru! I just tried to creat a blank environment through anaconda, and used conda installation again to accomplish it, finally.

I would close this issue.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.