
I was working on an NLP tool for evaluation purposes and found an issue in creating the environment. They had set up everything on Ubuntu so they might not face this issue but I am replicating on Centos 7 and found an error. Hope this will help someone.
The project is based on PyTorch 0.4+ and Python 3.6+. You can find that I have created the Python 3.6 on Centos 7 in my previous article
Now while installing Flair library using below command I am getting an issue:-
pip3.6 install flair
....
....
Collecting docutils>=0.10 (from botocore<1.13.0,>=1.12.71->boto3->pytorch-pretrained-bert==0.3.0->flair)
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. (read timeout=15)",)': /packages/36/fa/08e9e6e0e3cbd1d362c3bbee8d01d0aedb2155c4ac112b19ef3cae8eed8d/docutils-0.14-py3-none-any.whl
Downloading https://files.pythonhosted.org/packages/36/fa/08e9e6e0e3cbd1d362c3bbee8d01d0aedb2155c4ac112b19ef3cae8eed8d/docutils-0.14-py3-none-any.whl (543kB)
100% |████████████████████████████████| 552kB 11.3MB/s
Building wheels for collected packages: flair, segtok, mpld3, sklearn, sqlitedict, smart-open, regex, wrapt, future, networkx, bz2file
Building wheels for collected packages: regex
Running setup.py bdist_wheel for regex ... error
Complete output from command /root/mynlp/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-e_h664b3/regex/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-pajakj7c --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
copying regex_3/regex.py -> build/lib.linux-x86_64-3.6
copying regex_3/_regex_core.py -> build/lib.linux-x86_64-3.6
copying regex_3/test_regex.py -> build/lib.linux-x86_64-3.6
running build_ext
building '_regex' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/regex_3
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python3.6m -c regex_3/_regex.c -o build/temp.linux-x86_64-3.6/regex_3/_regex.o
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for regex
Resolution:-
To verify running below gcc command:-
(mynlp) [root@sandbox-host mynlp]# gcc -v
-bash: gcc: command not found
Run below command to install gcc under my virtual environment:-
(mynlp) [root@sandbox-host mynlp]# sudo yum install gcc
Installed:
gcc.x86_64 0:4.8.5-36.el7
....
....
Complete!
Now run
(mynlp) [root@sandbox-host mynlp]# pip3.6 install flair
Collecting flair
Requirement already satisfied: mpld3==0.3 in ./lib/python3.6/site-packages (from flair) (0.3)
Requirement already satisfied: sklearn in ./lib/python3.6/site-packages (from flair) (0.0)
Requirement already satisfied: tqdm==4.26.0 in ./lib/python3.6/site-packages (from flair) (4.26.0)
....
....
Requirement already satisfied: docutils>=0.10 in ./lib/python3.6/site-packages (from botocore<1.13.0,>=1.12.71->boto3->pytorch-pretrained-bert==0.3.0->flair) (0.14)
Building wheels for collected packages: regex
Running setup.py bdist_wheel for regex ... done
Stored in directory: /root/.cache/pip/wheels/56/b8/60/93cb6f51554e529246d89c994c1cba7b64d768ff1680062661
Successfully built regex
Installing collected packages: cycler, pyparsing, kiwisolver, matplotlib, regex, segtok, pytorch-pretrained-bert, wrapt, deprecated, pymongo, future, decorator, networkx, hyperopt, flair
Successfully installed cycler-0.10.0 decorator-4.3.0 deprecated-1.2.4 flair-0.4.0 future-0.17.1 hyperopt-0.1.1 kiwisolver-1.0.1 matplotlib-3.0.0 networkx-2.2 pymongo-3.7.2 pyparsing-2.3.0 pytorch-pretrained-bert-0.3.0 regex-2018.11.22 segtok-1.5.7 wrapt-1.10.11
To verify let’s run the example:-
(mynlp) [root@sandbox-host mynlp]# python
Python 3.6.7 (default, Dec 5 2018, 15:02:05)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from flair.data import Sentence
>>> from flair.models import SequenceTagger
That all and over. Happy Machine Learning!!!