Error in run_ner.py - ModuleNotFoundError: No module named 'tasks'
Author: danaludwig
Pull request: no
Labels: name: wontfix

## Environment info
- Google colab notebook.
- `transformers` version: 3.3.1
- Platform: Linux-4.19.112+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.6.9
- PyTorch version (GPU?): 1.6.0+cu101 (True)
- Tensorflow version (GPU?): not installed (NA)
- Using GPU in script?: yes
- Using distributed or parallel set-up in script?: no

### Who can help
@stefan-it

## Information

Model I am using is NER model
Script: run_ner.py:
https://github.com/huggingface/transformers/blob/master/examples/token-classification/run_ner.py

The problem arises when using:
* [X ] the official example scripts: (give details below)


The tasks I am working on is:
* building the NER model from model  "bert-base-multilingual-cased" using GermEval data with instructions here:
https://huggingface.co/transformers/v2.4.0/examples.html#named-entity-recognition

## To reproduce

Steps to reproduce the behavior:

```
# Eliminate --model_type; it creates an error and said it isn't used.
# sys.path.append(os.getcwd())
! python3 run_ner.py --data_dir ./ \
--labels ./labels.txt \
--model_name_or_path $BERT_MODEL \
--output_dir $OUTPUT_DIR \
--max_seq_length  $MAX_LENGTH \
--num_train_epochs $NUM_EPOCHS \
--per_gpu_train_batch_size $BATCH_SIZE \
--save_steps $SAVE_STEPS \
--seed $SEED \
--do_train \
--do_eval \
--do_predict

Error output:
/usr/local/lib/python3.6/dist-packages/transformers/training_args.py:332: FutureWarning: The `evaluate_during_training` argument is deprecated in favor of `evaluation_strategy` (which has more options)
  FutureWarning,
Traceback (most recent call last):
  File "run_ner.py", line 308, in <module>
    main()
  File "run_ner.py", line 118, in main
    module = import_module("tasks")
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tasks'
```

## Expected behavior

According to the example page, the model should get fine-tuned and tested on the GermEval test dataset.


Comments:
Update - this is not a bug in run_ner.py, but sort-of a documentation bug.  The page that describes how to do NER does not document that you first need to copy "tasks.py" and other scripts, into your local current directory.

https://github.com/huggingface/transformers/tree/master/examples/token-classification/README.md

For instance, you could provide a list of "wget" commands.  This may seem obvious to experienced developers, but it really helps to spell it out for the occasional clueless people like me :-)

Hello! In order to run the script, you should generally clone the repository and run the scripts from there. Running a single script will very rarely work. You'd be way safer doing the following (showing you the full setup + venv setup):

```py
git clone https://github.com/huggingface/transformers
cd transformers

python -m venv .env
source .env/bin/activate
pip install -e .

cd examples
pip install -r requirements.txt

# You can run your scripts now :)
```

Thank you; for future users, that would be super helpful to add that to the README.

Also, I think you need to cd to https://github.com/huggingface/transformers/tree/master/examples because the scripts assume that tasks.py etc are in the current directory.  But the “activate” may take care of that.

Thanks for everything – great software!

Dana

From: Lysandre Debut <notifications@github.com>
Sent: Thursday, October 15, 2020 2:00 AM
To: huggingface/transformers <transformers@noreply.github.com>
Cc: Ludwig, Dana <Dana.Ludwig@ucsf.edu>; Author <author@noreply.github.com>
Subject: Re: [huggingface/transformers] Error in run_ner.py - ModuleNotFoundError: No module named 'tasks' (#7773)


Hello! In order to run the script, you should generally clone the repository and run the scripts from there. Running a single script will very rarely work. You'd be way safer doing the following (showing you the full setup + venv setup):

git clone https://github.com/huggingface/transformers

cd transformers



python -m venv .env

source .env/bin/activate

pip install -e .



cd examples

pip install -r requirements.txt



# You can run your scripts now :)

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_huggingface_transformers_issues_7773-23issuecomment-2D709013098&d=DwMCaQ&c=iORugZls2LlYyCAZRB3XLg&r=A2YbHreGE4p0vzAywzM_Uctk-D3fPuXcmLPnjKJ7Gqc&m=QMIf0fCBI0DJve9mdTNWpHYcZNw6G6lbgNMtwt27-LI&s=_PAC-teAXIZpD6bvXaxJJooVSpQXCW-g1E0P6Xx0nzE&e=>, or unsubscribe<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ABUXNRIKGTLERRFCOBWSGRTSK22XTANCNFSM4SQGNKXQ&d=DwMCaQ&c=iORugZls2LlYyCAZRB3XLg&r=A2YbHreGE4p0vzAywzM_Uctk-D3fPuXcmLPnjKJ7Gqc&m=QMIf0fCBI0DJve9mdTNWpHYcZNw6G6lbgNMtwt27-LI&s=JROY2gIxImDPq_udIaCyPb85pHW64zCpy7-aa4ggSQY&e=>.


This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.