Page 1 of 1

Issue with running py4vasp

Posted: Tue Oct 10, 2023 6:47 pm
by pascal_boulet1
Dear all,

I have installed py4vasp on my MAC laptop following the tutorial py4vasp/latest/#installation.

I have first created an environment with conda (py4vasp-env) and then installed py4vasp within this environment with the commands:
conda install -c conda-forge mdtraj
pip install py4vasp

But now, I cannot run py4vasp. I have tried both from outside the environment and from inside it, but nothing works. I have also tried within a Jupyter notebook, same result!
When I type "import py4vasp" in the notebook the answer is:
ModuleNotFoundError Traceback (most recent call last)
/var/folders/xh/dmp4hwcd1792lslcn6v_wzrm0000gp/T/ipykernel_9654/3993992965.py in <module>
----> 1 import py4vasp

ModuleNotFoundError: No module named 'py4vasp'

One thing: I can see the py4vasp package (executable) in the directory ~/.conda/envs/py4vasp-env/bin, where is it supposed, I think, to be installed.

I don't understand what's going wrong.

Hints about this issue would be welcome.
Thank you
Pascal

Re: Issue with running py4vasp

Posted: Wed Oct 11, 2023 7:29 am
by martin.schlipf
I tried to reproduce this but so far I couldn't. The only thing I noticed was some trouble installing mdtraj in Python 3.12. Could you write exactly line by line how you setup the environment and then install py4vasp? For the record, I tried the following

Code: Select all

conda create -n demo python=3.11
conda activate demo
conda install -c conda-forge mdtraj
pip install py4vasp
If I do not set the python=3.11 constraint, conda cannot resolve the mdtraj dependency. Please report back, if the same instructions do not work on you machine and attach the output to the terminal so I can have a look.
pascal_boulet1 wrote: Tue Oct 10, 2023 6:47 pm One thing: I can see the py4vasp package (executable) in the directory ~/.conda/envs/py4vasp-env/bin, where is it supposed, I think, to be installed.
py4vasp should not install a py4vasp executable to that folder. However, you should see py4vasp in .conda/envs/py4vasp-env/lib/python3.11/site-packages .

Re: Issue with running py4vasp

Posted: Thu Oct 12, 2023 7:24 pm
by pascal_boulet1
Hello Martin,

Thank you for your reply. I have removed the py4vasp-env environment, recreated it and installed the packages following your instructions. I have gathered the terminal outputs in the attached text file.

Actually, it seems to work now. I have noticed that, the ~/.conda/environments.txt file was belonging to root, which was leading to an error when conda was trying to write in it. So I changed it so that I am the owner of the file. Could it be the reason for the failure of my previous installation? The second thing that has changed is the python version: in the previous one it was using python 3.7 by default. Now it is 3.11.

I am still facing some trouble: when I launch the jupyter notebook I get the error: Error displaying widget
For instance, here is the sequence of commands with the responses:
[1] import py4vasp
Error displaying widget
[2] calc = py4vasp.Calculation.from_path(".")
[3] calc.structure.plot()
Error displaying widget

I suppose I am missing some packages, but which ones?

Pascal

Re: Issue with running py4vasp

Posted: Fri Oct 13, 2023 8:28 am
by martin.schlipf
It sounds like the conda environment was missing a Python installation so it defaulted to the system Python. py4vasp requires Python >=3.8 which may also contribute to it not working as intended.

As for the widget not working: This sounds like an issue of the nglview package. Can you try

Code: Select all

import nglview
nglview.demo()
If that causes the same output, something went wrong with installing nglview.

Re: Issue with running py4vasp

Posted: Fri Oct 13, 2023 9:37 am
by pascal_boulet1
I am not well versed with python and co, I know I should learn, but don't have much time for this unfortunately, so I list below the commands I type on the terminal and the responses.
For nglview:
pascal@mcsete 06.PHON % conda activate py4vasp-env
(py4vasp-env) pascal@mcsete 06.PHON % python
Python 3.11.2 (main, Feb 16 2023, 16:29:15) [Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nglview
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'nglview'
>>> ^D
(py4vasp-env) pascal@mcsete 06.PHON % conda list

In this list I can see nglview:
...
nglview 3.0.8 pypi_0 pypi
...

For python 3.8: should I also install it in the py4vasp-env environment?

Re: Issue with running py4vasp

Posted: Fri Oct 13, 2023 9:51 am
by pascal_boulet1
For nglview again: if I open a jupyter notebook and type “import nglview” I get the same error: Error displaying widget
and the same with nglview.demo()

Re: Issue with running py4vasp

Posted: Fri Oct 13, 2023 10:41 am
by martin.schlipf
When you are in the conda enviroment and query

Code: Select all

which python
does it show a path within the conda environment?
pascal_boulet1 wrote: Fri Oct 13, 2023 9:37 am For python 3.8: should I also install it in the py4vasp-env environment?
Sorry for the confusion, I edited my previous post to clarify that it should be Python >=3.8 (but not 3.12 yet).
pascal_boulet1 wrote: Fri Oct 13, 2023 9:51 am For nglview again: if I open a jupyter notebook and type “import nglview” I get the same error: Error displaying widget
and the same with nglview.demo()
I could reproduce this. This is slightly different to my usual setup so I need to check what difference causes this issue. I will get back to you when I know. In the meantime the rest of the py4vasp commands that do not rely on plotting things in the structure should work fine.

Re: Issue with running py4vasp

Posted: Mon Oct 16, 2023 12:32 pm
by martin.schlipf
I am working on a more throughout fix at the moment but it seems downgrading the version of Jupyter notebook fixes this issue

Code: Select all

pip install "notebook<7"

Re: Issue with running py4vasp

Posted: Mon Oct 16, 2023 6:16 pm
by pascal_boulet1
Hello,

Yes, now it works.

Thank you
Pascal