QData / TextAttack

TextAttack šŸ™ is a Python framework for adversarial attacks, data augmentation, and model training in NLP https://textattack.readthedocs.io/en/master/
https://textattack.readthedocs.io/en/master/
MIT License
2.97k stars 398 forks source link

pip install bug #341

Closed Opdoop closed 4 years ago

Opdoop commented 4 years ago

Bug

install textattack through pip missing dependent package

Enviroment

Ubuntu 18.04.5 LTS conda 4.8.3

Reproducing

conda create -n textattack python=3.6
conda activate textattack
pip install textattack
textattack --help

Then encounter this:

textattack: Updating TextAttack package dependencies.
textattack: Downloading NLTK required packages.
[nltk_data] Downloading package averaged_perceptron_tagger to
[nltk_data]     /home/nano/nltk_data...
[nltk_data]   Unzipping taggers/averaged_perceptron_tagger.zip.
[nltk_data] Downloading package stopwords to /home/nano/nltk_data...
[nltk_data]   Unzipping corpora/stopwords.zip.
[nltk_data] Downloading package omw to /home/nano/nltk_data...
[nltk_data]   Unzipping corpora/omw.zip.
[nltk_data] Downloading package universal_tagset to
[nltk_data]     /home/nano/nltk_data...
[nltk_data]   Unzipping taggers/universal_tagset.zip.
[nltk_data] Downloading package wordnet to /home/nano/nltk_data...
[nltk_data]   Unzipping corpora/wordnet.zip.
[nltk_data] Downloading package punkt to /home/nano/nltk_data...
[nltk_data]   Package punkt is already up-to-date!
Traceback (most recent call last):
  File "/home/nano/anaconda3/envs/textattack/bin/textattack", line 5, in <module>
    from textattack.commands.textattack_cli import main
  File "/home/nano/anaconda3/envs/textattack/lib/python3.6/site-packages/textattack/__init__.py", line 12, in <module>
    from . import (
  File "/home/nano/anaconda3/envs/textattack/lib/python3.6/site-packages/textattack/attack_recipes/__init__.py", line 23, in <module>
    from .bae_garg_2019 import BAEGarg2019
  File "/home/nano/anaconda3/envs/textattack/lib/python3.6/site-packages/textattack/attack_recipes/bae_garg_2019.py", line 6, in <module>
    from textattack.constraints.grammaticality import PartOfSpeech
  File "/home/nano/anaconda3/envs/textattack/lib/python3.6/site-packages/textattack/constraints/__init__.py", line 24, in <module>
    from . import grammaticality
  File "/home/nano/anaconda3/envs/textattack/lib/python3.6/site-packages/textattack/constraints/grammaticality/__init__.py", line 10, in <module>
    from . import language_models
  File "/home/nano/anaconda3/envs/textattack/lib/python3.6/site-packages/textattack/constraints/grammaticality/language_models/__init__.py", line 10, in <module>
    from .google_language_model import Google1BillionWordsLanguageModel
  File "/home/nano/anaconda3/envs/textattack/lib/python3.6/site-packages/textattack/constraints/grammaticality/language_models/google_language_model/__init__.py", line 8, in <module>
    from .google_language_model import (
  File "/home/nano/anaconda3/envs/textattack/lib/python3.6/site-packages/textattack/constraints/grammaticality/language_models/google_language_model/google_language_model.py", line 13, in <module>
    from .alzantot_goog_lm import GoogLMHelper
  File "/home/nano/anaconda3/envs/textattack/lib/python3.6/site-packages/textattack/constraints/grammaticality/language_models/google_language_model/alzantot_goog_lm.py", line 18, in <module>
    from . import lm_data_utils, lm_utils
  File "/home/nano/anaconda3/envs/textattack/lib/python3.6/site-packages/textattack/constraints/grammaticality/language_models/google_language_model/lm_utils.py", line 14, in <module>
    from google.protobuf import text_format  # noqa: E402
ModuleNotFoundError: No module named 'google'

I tried pip install google and the pip freeze are below:

beautifulsoup4==4.9.3
bert-score==0.3.6
bpemb==0.3.2
certifi==2020.6.20
chardet==3.0.4
click==7.1.2
cloudpickle==1.6.0
cycler==0.10.0
dataclasses==0.8
datasets==1.1.2
decorator==4.4.2
Deprecated==1.2.10
dill==0.3.3
docopt==0.6.2
editdistance==0.5.3
filelock==3.0.12
flair==0.6.1.post1
ftfy==5.8
future==0.18.2
gdown==3.12.2
gensim==3.8.3
google==3.0.0
hyperopt==0.2.5
idna==2.10
Janome==0.4.1
joblib==0.17.0
kiwisolver==1.3.1
konoha==4.6.2
langdetect==1.0.8
language-tool-python==2.4.6
lemminflect==0.2.1
lru-dict==1.1.6
lxml==4.6.1
matplotlib==3.3.3
more-itertools==8.6.0
mpld3==0.3
multiprocess==0.70.11.1
networkx==2.5
nltk==3.5
num2words==0.5.10
numpy==1.18.5
overrides==3.0.0
packaging==20.4
pandas==1.1.4
Pillow==8.0.1
pyarrow==2.0.0
pyparsing==2.4.7
PySocks==1.7.1
python-dateutil==2.8.1
pytz==2020.4
regex==2020.11.13
requests==2.25.0
sacremoses==0.0.43
scikit-learn==0.23.2
scipy==1.4.1
segtok==1.5.10
sentencepiece==0.1.94
six==1.15.0
smart-open==3.0.0
soupsieve==2.0.1
sqlitedict==1.7.0
tabulate==0.8.7
terminaltables==3.1.0
textattack==0.2.12
threadpoolctl==2.1.0
tokenizers==0.8.1rc2
torch==1.7.0
tqdm==4.49.0
transformers==3.3.0
typing-extensions==3.7.4.3
urllib3==1.26.2
wcwidth==0.2.5
word2number==1.1
wrapt==1.12.1
xxhash==2.0.0

but still textattack --help gives ModuleNotFoundError: No module named 'google'

Opdoop commented 4 years ago

According stackflow solved by following command:

pip install --upgrade google-api-python-client

It's good to handle this bug and make installation pain-free šŸ‘

jxmorris12 commented 4 years ago

@Opdoop thanks for the fix, and the PR.

@jinyongyoo It looks like this problem happens bc the google lm depends on google.protobuf, which I'm assuming is installed when you install tensorflow. So now that tensorflow is optional, google.protobuf doesn't exist. Should we add google-api-python-client to the requirements.txt as is done in #342? Or should we make google lazily imported somehow?

qiyanjun commented 4 years ago

Thanks. Issues Solved.