Repository: doccano/doccano

Issue:
doccano init causes a ModuleNotFoundError for chardet
How to reproduce the behaviour
---------

Create a fresh virtualenv in which to test, then install the latest release of doccano from PyPi (v1.4.1):

```
$ virtualenv env
 [...virtualenv output removed...]

$ source env/bin/activate
(env) $ pip install doccano

 [... main output removed...]
Successfully installed Django-3.2.6 MarkupSafe-2.0.1 PyJWT-2.1.0 amqp-5.0.6 apache-libcloud-3.3.1 asgiref-3.4.1 auto-labeling-pipeline-0.1.21 billiard-3.6.4.0 boto3-1.18.30 botocore-1.21.30 celery-5.1.2 certifi-2021.5.30 cffi-1.14.6 charset-normalizer-2.0.4 click-7.1.2 click-didyoumean-0.0.3 click-plugins-1.1.1 click-repl-0.2.0 colour-0.1.5 conllu-4.4.1 coreapi-2.3.3 coreschema-0.0.4 cryptography-3.4.8 defusedxml-0.7.1 dj-database-url-0.5.0 dj-rest-auth-2.1.11 django-celery-results-2.2.0 django-cors-headers-3.8.0 django-drf-filepond-0.4.0 django-filter-2.4.0 django-polymorphic-3.0.0 django-rest-polymorphic-0.1.9 django-storages-1.11.1 djangorestframework-3.12.4 djangorestframework-csv-2.1.1 djangorestframework-xml-2.0.0 doccano-1.4.1 drf-yasg-1.20.0 ecdsa-0.17.0 environs-9.3.3 et-xmlfile-1.1.0 furl-2.1.2 greenlet-1.1.1 gunicorn-20.1.0 idna-3.2 inflection-0.5.1 itypes-1.2.0 jinja2-3.0.1 jmespath-0.10.0 joblib-1.0.1 kombu-5.1.0 lml-0.1.0 marshmallow-3.13.0 numpy-1.21.2 oauthlib-3.1.1 openpyxl-3.0.7 orderedmultidict-1.0.1 packaging-21.0 prompt-toolkit-3.0.20 pyasn1-0.4.8 pycparser-2.20 pydantic-1.8.2 pyexcel-0.6.6 pyexcel-io-0.6.4 pyexcel-xlsx-0.6.0 pyparsing-2.4.7 python-dateutil-2.8.2 python-dotenv-0.19.0 python-jose-3.3.0 python3-openid-3.2.0 pytz-2021.1 requests-2.26.0 requests-oauthlib-1.3.0 rsa-4.7.2 ruamel.yaml-0.17.14 ruamel.yaml.clib-0.2.6 s3transfer-0.5.0 scikit-learn-0.24.2 scipy-1.7.1 seqeval-1.2.2 shortuuid-1.0.1 six-1.16.0 social-auth-app-django-5.0.0 social-auth-core-4.1.0 sqlalchemy-1.4.23 sqlparse-0.4.1 texttable-1.6.4 threadpoolctl-2.2.0 typing-extensions-3.10.0.0 unicodecsv-0.14.1 uritemplate-3.0.1 urllib3-1.26.6 vine-5.0.0 wcwidth-0.2.5 whitenoise-5.3.0
```

Now run `doccano init`:
```
(env) $ doccano init
```

This results in a set of long stack traces all rooted on [doccano/backend/api/views/upload/dataset.py:L7](https://github.com/doccano/doccano/blob/3bf91c1e30c00693362491932a6aa802235a5f95/backend/api/views/upload/dataset.py#L7) - `import chardet`

```
Traceback (most recent call last):
  File "/env/lib/python3.8/site-packages/backend/manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/env/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/env/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/env/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)

[...traceback truncated...]

  File "/env/lib/python3.8/site-packages/backend/api/urls.py", line 3, in <module>
    from . import views
  File "/env/lib/python3.8/site-packages/backend/api/views/__init__.py", line 5, in <module>
    from .export_dataset import *
  File "/env/lib/python3.8/site-packages/backend/api/views/export_dataset.py", line 11, in <module>
    from ..tasks import export_dataset
  File "/env/lib/python3.8/site-packages/backend/api/tasks.py", line 13, in <module>
    from .views.upload.factory import (get_data_class, get_dataset_class,
  File "/env/lib/python3.8/site-packages/backend/api/views/upload/factory.py", line 3, in <module>
    from . import catalog, data, dataset, label
  File "/env/lib/python3.8/site-packages/backend/api/views/upload/dataset.py", line 7, in <module>
    import chardet
ModuleNotFoundError: No module named 'chardet'
```

`pip install chardet` resolves the issue and `doccano init` then completes successfully and I'm able to run the app. 

Your Environment
---------

*   **Operating System:** Tested on both macOS 10.15.7 and Ubuntu 20.04
*   **Python Version Used:** 3.8.9 (macOS, via macports), 3.8.10 (Ubuntu)
*   **When you install doccano:** 27th Aug 2021 - installing current release from PyPi, v1.4.1
*   **How did you install doccano (Heroku button etc):** Installing v1.4.1 from PyPi using `pip install doccano` into a clean python virtualenv.



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -43,6 +43,8 @@
     'sqlalchemy>=1.4.7',
     'gunicorn>=20.1.0',
     'waitress>=2.0.0',
+    'pydantic>=1.8.2',
+    'chardet>=4.0.0'
 ]
 
 setup(


Test patch: