mosdef-hub / foyer

A package for atom-typing as well as applying and disseminating forcefields
https://foyer.mosdef.org
MIT License
120 stars 78 forks source link

Foyer fails on Python 3.9 due to networkx error #414

Closed rsdefever closed 3 years ago

rsdefever commented 3 years ago

Bug summary

Working on a MoSDeF workflow. conda-forge defaulted me to python 3.9. I can also trivially reproduce this by creating a new conda environment with: conda create --name foyer foyer -c conda-forge

It appears networkx does not yet support Python 3.9 (https://networkx.org/documentation/stable/install.html).

I'm a little baffled why I was able to get a conda environment that was effectively broken from the start?

Upon import foyer, I get:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-45c4dbf19f8b> in <module>
      1 import mbuild
----> 2 import foyer
      3 import mosdef_cassandra as mc
      4 import unyt as u
      5 

~/software/miniconda3/envs/mc-prod/lib/python3.9/site-packages/foyer/__init__.py in <module>
----> 1 from foyer.forcefield import Forcefield
      2 from foyer.forcefields import forcefields
      3 
      4 __version__ = '0.8.0'
      5 

~/software/miniconda3/envs/mc-prod/lib/python3.9/site-packages/foyer/forcefield.py in <module>
     33 )
     34 
---> 35 from foyer.atomtyper import find_atomtypes
     36 from foyer.exceptions import FoyerError, MissingParametersError, MissingForceError
     37 from foyer import smarts

~/software/miniconda3/envs/mc-prod/lib/python3.9/site-packages/foyer/atomtyper.py in <module>
      5 
      6 from foyer.exceptions import FoyerError
----> 7 from foyer.topology_graph import TopologyGraph
      8 from foyer.smarts_graph import SMARTSGraph
      9 

~/software/miniconda3/envs/mc-prod/lib/python3.9/site-packages/foyer/topology_graph.py in <module>
----> 1 import networkx as nx
      2 from parmed import Structure
      3 
      4 from foyer.exceptions import FoyerError
      5 

~/software/miniconda3/envs/mc-prod/lib/python3.9/site-packages/networkx/__init__.py in <module>
    112 from networkx.relabel import *
    113 
--> 114 import networkx.generators
    115 from networkx.generators import *
    116 

~/software/miniconda3/envs/mc-prod/lib/python3.9/site-packages/networkx/generators/__init__.py in <module>
     12 from networkx.generators.expanders import *
     13 from networkx.generators.geometric import *
---> 14 from networkx.generators.intersection import *
     15 from networkx.generators.joint_degree_seq import *
     16 from networkx.generators.lattice import *

~/software/miniconda3/envs/mc-prod/lib/python3.9/site-packages/networkx/generators/intersection.py in <module>
     11 import random
     12 import networkx as nx
---> 13 from networkx.algorithms import bipartite
     14 from networkx.utils import py_random_state
     15 

~/software/miniconda3/envs/mc-prod/lib/python3.9/site-packages/networkx/algorithms/__init__.py in <module>
     14 from networkx.algorithms.cycles import *
     15 from networkx.algorithms.cuts import *
---> 16 from networkx.algorithms.dag import *
     17 from networkx.algorithms.distance_measures import *
     18 from networkx.algorithms.distance_regular import *

~/software/miniconda3/envs/mc-prod/lib/python3.9/site-packages/networkx/algorithms/dag.py in <module>
     21 
     22 from collections import defaultdict, deque
---> 23 from fractions import gcd
     24 from functools import partial
     25 from itertools import chain

ImportError: cannot import name 'gcd' from 'fractions' (/Users/ryandefever/software/miniconda3/envs/mc-prod/lib/python3.9/fractions.py)

Software versions

rsdefever commented 3 years ago

This error occurs with networkx=2.3, whereas if you build a conda environment with only networkx you get networkx=2.5 and the issue does not exist. I am not sure what dependency in foyer is pinning to an older networkx.