foyer icon indicating copy to clipboard operation
foyer copied to clipboard

Foyer not working when installed using `conda` but works with `mamba`

Open chrisjonesBSU opened this issue 2 years ago • 4 comments

Bug summary

I'm not sure if this ultimately stems from the foyer or gmso conda packages.

Installing foyer from conda-forge has different behavior depending if you use conda or mamba

It looks like you get different versions of pydantic depending on which method you use.

When installing with conda and trying to import foyer in python I get the following error:

>>> import foyer
Warning: importing 'simtk.openmm' is deprecated.  Import 'openmm' instead.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/chris/miniconda3/envs/foyer-conda/lib/python3.10/site-packages/foyer/__init__.py", line 2, in <module>
    from foyer.forcefield import Forcefield
  File "/home/chris/miniconda3/envs/foyer-conda/lib/python3.10/site-packages/foyer/forcefield.py", line 37, in <module>
    from foyer.atomtyper import find_atomtypes
  File "/home/chris/miniconda3/envs/foyer-conda/lib/python3.10/site-packages/foyer/atomtyper.py", line 6, in <module>
    from gmso import Topology
  File "/home/chris/miniconda3/envs/foyer-conda/lib/python3.10/site-packages/gmso/__init__.py", line 2, in <module>
    from .core.angle import Angle
  File "/home/chris/miniconda3/envs/foyer-conda/lib/python3.10/site-packages/gmso/core/angle.py", line 4, in <module>
    from pydantic import Field
ImportError: cannot import name 'Field' from 'pydantic' (/home/chris/miniconda3/envs/foyer-conda/lib/python3.10/site-packages/pydantic/__init__.py)

Installing with conda:

conda create -n foyer-conda -c conda-forge foyer -y
conda activate foyer-conda

I get these versions of foyer, gmso and pydantic:

foyer                     0.11.1             pyhd8ed1ab_0    conda-forge
gmso                      0.8.1              pyhd8ed1ab_0    conda-forge
pydantic                  0.18.2                     py_0    conda-forge

Installing with mamba:

mamba create -n foyer-mamba -c conda-forge foyer -y
mamba activate foyer-mamba

I get these versions of foyer, gmso and pydantic:

foyer                     0.11.1             pyhd8ed1ab_0    conda-forge
gmso                      0.8.1              pyhd8ed1ab_0    conda-forge
pydantic                  1.8.2                     py_0    conda-forge

Software versions mamba 0.24.0 conda 4.13.0 OS: Linux

I'm curious if anyone else can reproduce this. It's happened or myself and 2 other people in our lab.

chrisjonesBSU avatar Aug 09 '22 21:08 chrisjonesBSU

I tried this on my local and confirm the behavior shown above. I will into this and see what cause the difference.

daico007 avatar Aug 10 '22 13:08 daico007

Updates: I think the issue is with how conda and mamba solve package constraint.

  • When I called conda install pydantic and mamba install pydantic, both result in the latest version of pydantic (1.9.1) which is the expected behavior.
  • When I called conda install "pydantic<1.9.0" and mamba install "pydantic<1.9.0", the first call returned pydantic=0.18.2 and the latter returned version v1.8.2 (correct)

daico007 avatar Aug 10 '22 13:08 daico007

It's strange that the 3 numbers in the versions are the same; almost like it's a parsing or formatting error or something (I don't really know how conda does all this under the hood).

Maybe one solution is to pin the exact version of 1.8.2 in the gmso requirements rather than using <1.9.0

conda install pydantic=1.8.2 seems to work for me.

chrisjonesBSU avatar Aug 10 '22 15:08 chrisjonesBSU

Raised an issue with conda

daico007 avatar Aug 10 '22 15:08 daico007