RockyLzy / TextDefender

codes for "Searching for an Effective Defender:Benchmarking Defense against Adversarial Word Substitution"
MIT License
31 stars 2 forks source link

Import error #5

Closed Han8931 closed 2 years ago

Han8931 commented 2 years ago

Hi, I run the main.py bypyhon3 main.py and I got the following error How can I fix this issue?

Traceback (most recent call last):
  File "main.py", line 5, in <module>
    from args import ProgramArgs, string_to_bool
  File "/data/han/TextDefender/args.py", line 7, in <module>
    from trainer import TRAINER_REGISTRY
  File "/data/han/TextDefender/trainer/__init__.py", line 38, in <module>
    module = importlib.import_module("trainer." + model_name)
  File "/home/han/anaconda3/envs/textdefender/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/data/han/TextDefender/trainer/hotflip.py", line 13, in <module>
    from torchnlp.samplers.bucket_batch_sampler import BucketBatchSampler
  File "/home/han/anaconda3/envs/textdefender/lib/python3.8/site-packages/torchnlp/samplers/__init__.py", line 1, in <module>
    from torchnlp.samplers.balanced_sampler import BalancedSampler
  File "/home/han/anaconda3/envs/textdefender/lib/python3.8/site-packages/torchnlp/samplers/balanced_sampler.py", line 1, in <module>
    from torchnlp._third_party.weighted_random_sampler import WeightedRandomSampler
  File "/home/han/anaconda3/envs/textdefender/lib/python3.8/site-packages/torchnlp/_third_party/weighted_random_sampler.py", line 4, in <module>
    from torch._six import int_classes as _int_classes
ImportError: cannot import name 'int_classes' from 'torch._six' (/home/han/anaconda3/envs/textdefender/lib/python3.8/site-packages/torch/_six.py)