hspark1212 / MOFTransformer

Universal Transfer Learning in Porous Materials, including MOFs.
https://hspark1212.github.io/MOFTransformer/
86 stars 13 forks source link

Linux cli error (AttributeError: _DistInfoDistribution__dep_map) #127

Closed MINGUUUS closed 1 year ago

MINGUUUS commented 1 year ago

Hello!

I have installed MOFTransformer v2.1.0 in editable mode, and then I have tried to download pretraining model by using Linux command.

$ moftransformer download pretrain_model

But there is an error like below.

Traceback (most recent call last):
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3108, in _dep_map
    return self.__dep_map
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2901, in __getattr__
    raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 35, in __init__
    parsed = parse_requirement(requirement_string)
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/_parser.py", line 64, in parse_requirement
    return _parse_requirement(Tokenizer(source, rules=DEFAULT_RULES))
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/_parser.py", line 82, in _parse_requirement
    url, specifier, marker = _parse_requirement_details(tokenizer)
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/_parser.py", line 120, in _parse_requirement_details
    specifier = _parse_specifier(tokenizer)
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/_parser.py", line 209, in _parse_specifier
    tokenizer.consume("WS")
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/contextlib.py", line 126, in __exit__
    next(self.gen)
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/_tokenizer.py", line 183, in enclosing_tokens
    self.raise_syntax_error(
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/_tokenizer.py", line 163, in raise_syntax_error
    raise ParserSyntaxError(
pkg_resources.extern.packaging._tokenizer.ParserSyntaxError: Expected closing RIGHT_PARENTHESIS
    torch (>=1.9.*)
          ~~~~~~^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/mingyu/anaconda3/envs/PMTransformer/bin/moftransformer", line 33, in <module>
    sys.exit(load_entry_point('moftransformer', 'console_scripts', 'moftransformer')())
  File "/home/mingyu/anaconda3/envs/PMTransformer/bin/moftransformer", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/importlib/metadata.py", line 86, in load
    module = import_module(match.group('module'))
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/mingyu/MOFTransformer/moftransformer/__init__.py", line 7, in <module>
    from moftransformer import visualize, utils, modules, libs, gadgets, datamodules, assets
  File "/home/mingyu/MOFTransformer/moftransformer/visualize/__init__.py", line 2, in <module>
    from moftransformer.visualize.visualizer import PatchVisualizer
  File "/home/mingyu/MOFTransformer/moftransformer/visualize/visualizer.py", line 12, in <module>
    from moftransformer.visualize.utils import (
  File "/home/mingyu/MOFTransformer/moftransformer/visualize/utils.py", line 16, in <module>
    import pytorch_lightning as pl
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pytorch_lightning/__init__.py", line 34, in <module>
    from pytorch_lightning.callbacks import Callback  # noqa: E402
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pytorch_lightning/callbacks/__init__.py", line 14, in <module>
    from pytorch_lightning.callbacks.callback import Callback
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pytorch_lightning/callbacks/callback.py", line 25, in <module>
    from pytorch_lightning.utilities.types import STEP_OUTPUT
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pytorch_lightning/utilities/__init__.py", line 18, in <module>
    from pytorch_lightning.utilities.apply_func import move_data_to_device  # noqa: F401
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pytorch_lightning/utilities/apply_func.py", line 30, in <module>
    from pytorch_lightning.utilities.imports import _compare_version, _TORCHTEXT_LEGACY
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pytorch_lightning/utilities/imports.py", line 22, in <module>
    import pkg_resources
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3327, in <module>
    def _initialize_master_working_set():
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3301, in _call_aside
    f(*args, **kwargs)
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3339, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/__init__.py", line 629, in _build_master
    ws.require(__requires__)
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/__init__.py", line 966, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/__init__.py", line 832, in resolve
    new_requirements = dist.requires(req.extras)[::-1]
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/__init__.py", line 2821, in requires
    dm = self._dep_map
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3110, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3120, in _compute_dependencies
    reqs.extend(parse_requirements(req))
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3173, in __init__
    super(Requirement, self).__init__(requirement_string)
  File "/home/mingyu/anaconda3/envs/PMTransformer/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 37, in __init__
    raise InvalidRequirement(str(e)) from e
pkg_resources.extern.packaging.requirements.InvalidRequirement: Expected closing RIGHT_PARENTHESIS
    torch (>=1.9.*)
          ~~~~~~^

If I used python interpreter, it works well.

$ python
    from moftransformer.utils.download import download_pretrain_model
    download_pretrain_model()

I don't know why this happens. Could you please help me?

Thank you in advance!

Yeonghun1675 commented 1 year ago

Hi, @MINGUUUS!

We have found that the issue is related to setuptools. Please try uninstalling moftransformer, upgrading to the latest version of setuptools and reinstalling it. We have found that this works for us when running in a similar environment. If this doesn't work for you, please let us know.