Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not enough values to unpack (expected at least 2, got 1) #98

Open
mghahremanpour opened this issue Jan 13, 2025 · 8 comments
Open

not enough values to unpack (expected at least 2, got 1) #98

mghahremanpour opened this issue Jan 13, 2025 · 8 comments
Assignees

Comments

@mghahremanpour
Copy link

I installed openff-interchange with conda install -c conda-forge openff-interchange or conda install conda-forge::openff-interchange

but I get this error when trying to import in iPython:

 36 package_versions = {}
 38 for output_line in output[3:-1]:
 39     # The output format of `conda`/`mamba list` and `micromamba list` are different.
 40     # See https://github.com/openforcefield/openff-utilities/issues/65

---> 41 package_name, package_version, *_ = output_line.split()
42 package_versions[package_name] = package_version
44 return package_versions

ValueError: not enough values to unpack (expected at least 2, got 1)

@mattwthompson
Copy link
Member

Could you run this script, following the instructions at the top? It'd help us reproduce the error

https://github.com/openforcefield/status/blob/main/devtools/support/debug.sh

@mghahremanpour
Copy link
Author

mghahremanpour commented Jan 13, 2025

Unfortunately, it prints out too many details of our HPC configs and other loaded libraries some of which are commercial; I am afraid that I cannot share them.

These are what I get when importing Interchange


In [1]: from openff.interchange import Interchange
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[1], line 1
----> 1 from openff.interchange import Interchange

File <frozen importlib._bootstrap>:1229, in _handle_fromlist(module, fromlist, import_, recursive)

File ~/workspace/.conda/envs/DDT/lib/python3.11/site-packages/openff/interchange/__init__.py:33, in __getattr__(name)
     31 if module is not None:
     32     try:
---> 33         return importlib.import_module(module).__dict__[name]
     34     except ImportError as error:
     35         raise ImportError from error

File ~/workspace/.conda/envs/DDT/lib/python3.11/importlib/__init__.py:126, in import_module(name, package)
    124             break
    125         level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)

File ~/workspace/.conda/envs/DDT/lib/python3.11/site-packages/openff/interchange/components/interchange.py:8
      5 from pathlib import Path
      6 from typing import TYPE_CHECKING, Literal, Union, overload
----> 8 from openff.toolkit import ForceField, Molecule, Quantity, Topology, unit
      9 from openff.utilities.utilities import has_package, requires_package
     10 from pydantic import Field

File <frozen importlib._bootstrap>:1229, in _handle_fromlist(module, fromlist, import_, recursive)

File ~/workspace/.conda/envs/DDT/lib/python3.11/site-packages/openff/toolkit/__init__.py:80, in __getattr__(name)
     78 obj_mod = _lazy_imports_obj.get(name)
     79 if obj_mod is not None:
---> 80     mod = importlib.import_module(obj_mod)
     81     try:
     82         return mod.__dict__[name]

File ~/workspace/.conda/envs/DDT/lib/python3.11/importlib/__init__.py:126, in import_module(name, package)
    124             break
    125         level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)

File ~/workspace/.conda/envs/DDT/lib/python3.11/site-packages/openff/toolkit/typing/engines/smirnoff/__init__.py:1
----> 1 from openff.toolkit.typing.engines.smirnoff.forcefield import (
      2     ForceField,
      3     get_available_force_fields,
      4 )
      5 from openff.toolkit.typing.engines.smirnoff.io import (
      6     ParameterIOHandler,
      7     XMLParameterIOHandler,
      8 )
      9 from openff.toolkit.typing.engines.smirnoff.parameters import (
     10     AngleHandler,
     11     BondHandler,
   (...)
     29     vdWHandler,
     30 )

File ~/workspace/.conda/envs/DDT/lib/python3.11/site-packages/openff/toolkit/typing/engines/smirnoff/forcefield.py:35
     33 from openff.toolkit import Quantity
     34 from openff.toolkit.typing.engines.smirnoff.io import ParameterIOHandler
---> 35 from openff.toolkit.typing.engines.smirnoff.parameters import ParameterHandler
     36 from openff.toolkit.typing.engines.smirnoff.plugins import load_handler_plugins
     37 from openff.toolkit.utils.constants import (
     38     ALLOWED_AROMATICITY_MODELS,
     39     DEFAULT_AROMATICITY_MODEL,
     40 )

File ~/workspace/.conda/envs/DDT/lib/python3.11/site-packages/openff/toolkit/typing/engines/smirnoff/parameters.py:68
     65 from packaging.version import Version
     67 from openff.toolkit import Quantity, unit
---> 68 from openff.toolkit.topology import ImproperDict, TagSortedDict, Topology, ValenceDict
     69 from openff.toolkit.topology.molecule import Molecule
     70 from openff.toolkit.utils.collections import ValidatedDict, ValidatedList

File ~/workspace/.conda/envs/DDT/lib/python3.11/site-packages/openff/toolkit/topology/__init__.py:1
----> 1 from openff.toolkit.topology.molecule import (
      2     Atom,
      3     Bond,
      4     FrozenMolecule,
      5     HierarchyElement,
      6     HierarchyScheme,
      7     Molecule,
      8     Particle,
      9 )
     10 from openff.toolkit.topology.topology import (
     11     DuplicateUniqueMoleculeError,
     12     ImproperDict,
   (...)
     21     ValenceDict,
     22 )
     24 __all__ = [
     25     "Atom",
     26     "Bond",
   (...)
     42     "ValenceDict",
     43 ]

File ~/workspace/.conda/envs/DDT/lib/python3.11/site-packages/openff/toolkit/topology/molecule.py:54
     51 from typing_extensions import TypeAlias
     53 from openff.toolkit import Quantity, unit
---> 54 from openff.toolkit.utils.constants import DEFAULT_AROMATICITY_MODEL
     55 from openff.toolkit.utils.exceptions import (
     56     AtomMappingWarning,
     57     BondExistsError,
   (...)
     75     UnsupportedFileTypeError,
     76 )
     77 from openff.toolkit.utils.serialization import Serializable

File ~/workspace/.conda/envs/DDT/lib/python3.11/site-packages/openff/toolkit/utils/__init__.py:10
      1 from openff.toolkit.utils.constants import (
      2     ALLOWED_AROMATICITY_MODELS,
      3     ALLOWED_CHARGE_MODELS,
   (...)
      7     DEFAULT_FRACTIONAL_BOND_ORDER_MODEL,
      8 )
      9 from openff.toolkit.utils.toolkit_registry import toolkit_registry_manager
---> 10 from openff.toolkit.utils.toolkits import (
     11     AMBERTOOLS_AVAILABLE,
     12     BASIC_CHEMINFORMATICS_TOOLKITS,
     13     GLOBAL_TOOLKIT_REGISTRY,
     14     OPENEYE_AVAILABLE,
     15     RDKIT_AVAILABLE,
     16     AmberToolsToolkitWrapper,
     17     AntechamberNotFoundError,
     18     BuiltInToolkitWrapper,
     19     ChargeCalculationError,
     20     ChargeMethodUnavailableError,
     21     GAFFAtomTypeWarning,
     22     IncompatibleUnitError,
     23     IncorrectNumConformersError,
     24     IncorrectNumConformersWarning,
     25     InvalidIUPACNameError,
     26     InvalidToolkitError,
     27     InvalidToolkitRegistryError,
     28     LicenseError,
     29     MissingPackageError,
     30     OpenEyeToolkitWrapper,
     31     RDKitToolkitWrapper,
     32     SMILESParseError,
     33     ToolkitRegistry,
     34     ToolkitUnavailableException,
     35     ToolkitWrapper,
     36     UndefinedStereochemistryError,
     37 )
     38 from openff.toolkit.utils.utils import (
     39     all_subclasses,
     40     convert_0_1_smirnoff_to_0_2,
   (...)
     55     unit_to_string,
     56 )

File ~/workspace/.conda/envs/DDT/lib/python3.11/site-packages/openff/toolkit/utils/toolkits.py:102
     98 logger = logging.getLogger(__name__)
    101 # Create global toolkit registry, where all available toolkits are registered
--> 102 GLOBAL_TOOLKIT_REGISTRY = ToolkitRegistry(
    103     toolkit_precedence=[
    104         OpenEyeToolkitWrapper,
    105         RDKitToolkitWrapper,
    106         AmberToolsToolkitWrapper,
    107         BuiltInToolkitWrapper,
    108     ],
    109     exception_if_unavailable=False,
    110 )
    111 """
    112 The toolkit registry used by default when no registry or wrapper is specified.
    113 
   (...)
    165 toolkit_registry_manager, ToolkitRegistry, ToolkitWrapper
    166 """
    169 OPENEYE_AVAILABLE = False

File ~/workspace/.conda/envs/DDT/lib/python3.11/site-packages/openff/toolkit/utils/toolkit_registry.py:127, in ToolkitRegistry.__init__(self, toolkit_precedence, exception_if_unavailable, _register_imported_toolkit_wrappers)
    125 if toolkit_classes_to_register:
    126     for toolkit in toolkit_classes_to_register:
--> 127         self.register_toolkit(
    128             toolkit_wrapper=toolkit,
    129             exception_if_unavailable=exception_if_unavailable,
    130         )

File ~/workspace/.conda/envs/DDT/lib/python3.11/site-packages/openff/toolkit/utils/toolkit_registry.py:314, in ToolkitRegistry.register_toolkit(self, toolkit_wrapper, exception_if_unavailable)
    312 elif issubclass(toolkit_wrapper, ToolkitWrapper):
    313     try:
--> 314         _toolkit_wrapper = toolkit_wrapper()
    316     # This exception can be raised by OpenEyeToolkitWrapper
    317     except LicenseError as license_exception:

File ~/workspace/.conda/envs/DDT/lib/python3.11/site-packages/openff/toolkit/utils/ambertools_wrapper.py:74, in AmberToolsToolkitWrapper.__init__(self)
     68 if not self.is_available():
     69     raise ToolkitUnavailableException(
     70         f"The required toolkit {self._toolkit_name} is not "
     71         f"available. {self._toolkit_installation_instructions}"
     72     )
---> 74 self._toolkit_version = get_ambertools_version()
     76 # TODO: Find AMBERHOME or executable home, checking miniconda if needed
     77 # Store an instance of an RDKitToolkitWrapper for file I/O
     78 self._rdkit_toolkit_wrapper = rdkit_wrapper.RDKitToolkitWrapper()

File ~/workspace/.conda/envs/DDT/lib/python3.11/site-packages/openff/utilities/provenance.py:58, in get_ambertools_version()
     47 def get_ambertools_version() -> Optional[str]:
     48     """
     49     Attempts to retrieve the version of the currently installed AmberTools.
     50 
   (...)
     55             still returns `None`, but without a warning associated with the above failure.
     56     """
---> 58     return _get_conda_list_package_versions().get("ambertools", None)

File ~/workspace/.conda/envs/DDT/lib/python3.11/site-packages/openff/utilities/provenance.py:41, in _get_conda_list_package_versions()
     36 package_versions = {}
     38 for output_line in output[3:-1]:
     39     # The output format of `conda`/`mamba list` and `micromamba list` are different.
     40     # See https://github.com/openforcefield/openff-utilities/issues/65
---> 41     package_name, package_version, *_ = output_line.split()
     42     package_versions[package_name] = package_version
     44 return package_versions

ValueError: not enough values to unpack (expected at least 2, got 1)

@mghahremanpour
Copy link
Author

I can import openff fine by import openff but not Interchange.

@mattwthompson
Copy link
Member

mattwthompson commented Jan 13, 2025

Short of that, how about

  1. What is the virtual environment provider? How is it installed?
  2. What is the output of conda info && conda list?

Something is probably wrong with the conda setup and/or packages are out of date; something shorter like from openff.toolkit import __version__ should be enough to reproduce

Unfortunately, import openff doesn't do anything even if it runs without error; the stub of namespace packages is a sort of placeholder that holds no functionality. from openff.toolkit import Molecule, for example, is where stuff gets started.

@mghahremanpour
Copy link
Author

conda.log

How is it installed?
conda install conda-forge::openff-interchange

You can file the output of conda list in conda.log (attached)

Thanks,

@mattwthompson
Copy link
Member

Those versions look pretty good from a cursory glance through. Thanks for sharing how you're installing Interchange

How are you getting conda? Miniconda, Miniforge, something from Anaconda Inc., or something else? We haven't been seeing this with our various virtual environment solutions - most of what I listed above plus a few miniconda setups - so I need to better understand your setup in order to reproduce this error.

@mghahremanpour
Copy link
Author

I am not sure what you need to know from my setup exactly, but our conda is installed from Anaconda3. It is conda 4.12.0.

@j-wags j-wags assigned j-wags and mattwthompson and unassigned j-wags Jan 13, 2025
@mattwthompson
Copy link
Member

I'm having a hard time reproducing this; if the file you attached is the output of conda list it does not trigger this error on its own

>>> len([line.split() for line in open("/Users/mattthompson/Downloads/conda.log").readlines()[3:-1]])
446

I downloaded Anaconda's most recent iteration of their "distribution" from here, installed it, created a fresh environment (conda create --name issue-98 openff-interchange -c conda-forge), and didn't run into this issue

$ which python                                                                   13:07:42
/opt/anaconda3/envs/issue-98/bin/python
(issue-98) [~]
$ python                                                                         13:08:04
Python 3.12.8 | packaged by conda-forge | (main, Dec  5 2024, 14:19:53) [Clang 18.1.8 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from openff.interchange import Interchange
/opt/anaconda3/envs/issue-98/lib/python3.12/site-packages/openff/utilities/provenance.py:23: CondaExecutableNotFoundWarning: No conda/mamba/micromamba executable found. Unable to determine package versions.
  warnings.warn(
>>>

If there is anything non-standard about your setup, or other information that would be necessary for me to be able to reproduce this error, I'd be happy to try again!

We do recommend Miniforge (previously known as Mambaforge) as a drop-in replacement for and strict improvement over Anaconda's distributions: https://docs.openforcefield.org/en/latest/install.html#installing-mamba

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants