elcorto / pwtools

pwtools is a Python package for pre- and postprocessing of atomistic calculations, mostly targeted to Quantum Espresso, CPMD, CP2K and LAMMPS. It is almost, but not quite, entirely unlike ASE, with some tools extending numpy/scipy. It has a set of powerful parsers and data types for storing calculation data.
https://elcorto.github.io/pwtools
BSD 3-Clause "New" or "Revised" License
64 stars 12 forks source link

Problem with installation on Windows #4

Closed carlosbornes closed 3 years ago

carlosbornes commented 3 years ago

I'm trying to install Pwtools on Windows and I'm having a hard time

I've installed Pwtool using

git clone https://github.com/elcorto/pwtools.git
pip install -e pwtools

Everything went well, at least no errors. But when I try to run

from pwtools import io
from ase.visualize import view

traj = io.read_cp2k_md('zeo_opti.log')
view(traj)`

I get the following error

cannot import name '_flib' from 'pwtools' (c:\users\cb\pwtools\pwtools\__init__.py)

Is there a way to troubleshoot this?

elcorto commented 3 years ago

Hi, thanks for your interest in the project!

As ~documented~ used to be documented here, pip install -e doesn't build extension modules (current master cee068d), of which _flib is one, so you need to build them first. This is actually not supposed to be the case, and we'll track that in #5. Thanks for making me find this issue!

Anyhow, I'm afraid that since we use GNU Make and by default the gfortran compiler in the build step, that probably won't work on Windows. I don't have access to a Windows machine so I also can't offer any help there. You might try WSL or https://www.cygwin.com.

In general you can use large parts of the package without having the extensions build and one hack is to just comment out the imports in these files

$ find . -maxdepth 1 -name "*.py" | xargs grep -l 'import.*_flib'                                                                                            n
./crys.py
./random.py
./num.py
./pydos.py

But, io.read_cp2k_md does actually use the _flib extension to calculate coordinate transformations.

If I find the time, I'll probably port the Fortran extensions and the way we build them to a more cross-platform solution, but I'm afraid I can't offer any other short-term solution here.

elcorto commented 3 years ago

You can manually try to build extensions:

$ cd src && make clean && make && cd ..

That should give you a build error on Windows.

elcorto commented 3 years ago

Looking at your code,

traj = io.read_cp2k_md('zeo_opti.log')
view(traj)

won't work because traj is a pwtools Trajectory which is not compatible with ASE. We have struct2atoms for single structs but not trajectories. I think it is probably pretty easy to add support for that, I just never had that use case.

You may want to check out visualize where we have interfaces to VMD and others. For long MD trajs, I recommend VMD anyway. For short (< ~100 steps) relax runs and that sort of thing, xcrysden is also ok.

elcorto commented 3 years ago

@CBornes if you found a solution to build on Windows, feel free to share that here as future reference for other users.

You might also consider replacing the extension-dependent parts of the parser you plan on using with slower numpy-only code. That is pretty straight forward, but I don't have the time and need to implement and test that at the moment, unfortunately. PRs are always welcome!

Since there was no feedback on the info I gave above, I'm taking the liberty to close this one. Feel free to re-open. Thanks for reporting!