# problem using GPAW in Google Colab

I am trying to follow the following: https://peterschindler.github.io/ This is searchable on the internet and it shows how to use GPAW as an ASE calculator. The installation is done by

!apt install ase
!apt install gpaw


After the installation is finished, I tried running the cell below it:

from ase import Atoms #The Atoms object is used to define and work with atomic structure in ASE
from ase.io import read, write #The ase.io module is used to read and write crystal/molecular structure files
from gpaw import GPAW, PW #GPAW will be our main DFT calculator and PW is the plane wave mode

h2 = Atoms('H2', [(0, 0, 0), (0, 0, 0.74)])
h2.center(vacuum=2.5)

calc = GPAW(xc='LDA',
kpts=(1,1,1),
mode=PW(500),
txt='h2.txt')

h2.set_calculator(calc)

print(h2.get_potential_energy())


I got the following error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-6-bf8aeb87a66d> in <module>()
1 from ase import Atoms #The Atoms object is used to define and work with atomic structure in ASE
2 from ase.io import read, write #The ase.io module is used to read and write crystal/molecular structure files
----> 3 from gpaw import GPAW, PW #GPAW will be our main DFT calculator and PW is the plane wave mode
4
5 h2 = Atoms('H2', [(0, 0, 0), (0, 0, 0.74)])

3 frames
/usr/lib/python3/dist-packages/gpaw/utilities/__init__.py in <module>()
11 from numpy import linalg
12
---> 13 import _gpaw
14 from gpaw import debug
15

ModuleNotFoundError: No module named '_gpaw'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------



How do I resolve this?

P.S.

I already tried using pip install instead. Still gives the same error.

I also tried doing the test calculation found on this page: https://pypi.org/project/gpaw/:  ! gpaw test but it gave the same error: no module _gpaw

I also tried opening the file located at: /usr/lib/python3/dist-packages/gpaw/utilities/init.py and although I'm not sure if it's the right thing to do, I tried replacing all keywords _gpaw with just gpawbut then it just results in many other errors referring to some attribute not being defined.

• Probably the version is important report. apt packages can be somewhat slower to be updated than those from pip. I would suggest following the installation instructions from the GPAW documentation, rather than from an article which may be out of date: wiki.fysik.dtu.dk/gpaw/install.html There seems to be a related issue on the tracker: gitlab.com/gpaw/gpaw/-/issues/348 Apr 28 at 2:40

I hope it's okay to "self-answer". So I also posted this question in the GPAW mailing list and one of the users in the mailing list who go by the handle mazay0 offered a different means of installing gpaw as follows:

!apt install python3-mpi4py cython3 libxc-dev gpaw-data
!pip -q install gpaw pymatgen==2019.12.22


This one worked. Although, I still don't have any idea why this one works while the shorter way doesn't. I'm not really good with bash commands (Maybe someone can explain(?)).

As per the comment above, it seems other people have also stumbled on this problem. The code snippet above seemed to do the trick in my case.

• Yes it's perfectly fine to self-answer, but in this case it would have been best if you clicked the "community wiki" button when answering this question, since it's not really your answer and the credit really ought to go to mazay0 instead of to you. Also please try to get that user to come here and answer some of our GPAW questions! Apr 28 at 18:44
• Oh okay how do I do the community wiki thing? It seems like its already on community wiki though
– jboy
Apr 29 at 3:23
• A moderator did it for you this time. Typically when you write an answer, there's a box that you can check to make the answer a community wiki. Once you have written the answer, it's only possible for a moderator to do it though. Apr 29 at 5:02