Cuckoo Install Failure(pillow)

Cuckoo Install Failure(pillow)

Baisc Info:

  • Error Message: Failed building wheel for pillow
  • OS: Ubuntu 16.04 LST
  • Cuckoo: 2.0.5
  • Python Version: 2.7
  • Python Virtual Environment: Conda

Error Situation

通過pip安裝cuckoo時,遇到以下錯誤:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
(cuckoo) albert@zhuang-pc:~$ pip install cuckoo
Collecting cuckoo
Requirement already satisfied: unicorn==1.0.1 in ./miniconda2/envs/cuckoo/lib/python2.7/site-packages (from cuckoo)
Requirement already satisfied: alembic==0.8.8 in ./miniconda2/envs/cuckoo/lib/python2.7/site-packages (from cuckoo)
Requirement already satisfied: wakeonlan==0.2.2 in ./miniconda2/envs/cuckoo/lib/python2.7/site-packages (from cuckoo)
Collecting sflock<0.3,>=0.2.15 (from cuckoo)
# ...
Collecting pycparser (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography>=1.3.4; extra == "security"->requests[security]==2.13.0; sys_platform == "linux2"->cuckoo)
Building wheels for collected packages: pillow
Running setup.py bdist_wheel for pillow ... error
Complete output from command /home/albert/miniconda2/envs/cuckoo/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-s5clPe/pillow/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/tmpN75cBapip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_py
creating build
# ...
building 'PIL._imagingtk' extension
creating build/temp.linux-x86_64-2.7/Tk
Building using 4 processes
gcc -pthread -B /home/albert/miniconda2/envs/cuckoo/compiler_compat -Wl,--sysroot=/ -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip-build-s5clPe/pillow/libImaging -I/home/albert/miniconda2/envs/cuckoo/include -I/usr/local/include -I/usr/include -I/home/albert/miniconda2/envs/cuckoo/include/python2.7 -I/usr/include/x86_64-linux-gnu -c _imagingtk.c -o build/temp.linux-x86_64-2.7/_imagingtk.o
gcc -pthread -B /home/albert/miniconda2/envs/cuckoo/compiler_compat -Wl,--sysroot=/ -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip-build-s5clPe/pillow/libImaging -I/home/albert/miniconda2/envs/cuckoo/include -I/usr/local/include -I/usr/include -I/home/albert/miniconda2/envs/cuckoo/include/python2.7 -I/usr/include/x86_64-linux-gnu -c Tk/tkImaging.c -o build/temp.linux-x86_64-2.7/Tk/tkImaging.o
In file included from Tk/tkImaging.c:52:0:
/home/albert/miniconda2/envs/cuckoo/include/tk.h:96:25: fatal error: X11/Xlib.h: No such file or directory
compilation terminated.
In file included from _imagingtk.c:19:0:
/home/albert/miniconda2/envs/cuckoo/include/tk.h:96:25: fatal error: X11/Xlib.h: No such file or directory
compilation terminated.
gcc -pthread -shared -B /home/albert/miniconda2/envs/cuckoo/compiler_compat -L/home/albert/miniconda2/envs/cuckoo/lib -Wl,-rpath=/home/albert/miniconda2/envs/cuckoo/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-2.7/_imagingtk.o build/temp.linux-x86_64-2.7/Tk/tkImaging.o -L/home/albert/miniconda2/envs/cuckoo/lib -L/lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib -L/usr/lib -L/home/albert/miniconda2/envs/cuckoo/lib -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ltk8.6 -lpython2.7 -o build/lib.linux-x86_64-2.7/PIL/_imagingtk.so
gcc: error: build/temp.linux-x86_64-2.7/_imagingtk.o: No such file or directory
gcc: error: build/temp.linux-x86_64-2.7/Tk/tkImaging.o: No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for pillow
Running setup.py clean for pillow
Failed to build pillow
Installing collected packages: pillow, peepdf, olefile, python-magic, sflock, scapy, pymongo, idna, pycparser, cffi, enum34, asn1crypto, ipaddress, cryptography, pyOpenSSL, requests, pyelftools, yara-python, python-dateutil, functools32, jsonschema, pymisp, pefile2, cuckoo
Found existing installation: Pillow 4.3.0
Uninstalling Pillow-4.3.0:
Successfully uninstalled Pillow-4.3.0
Running setup.py install for pillow ... error
Complete output from command /home/albert/miniconda2/envs/cuckoo/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-s5clPe/pillow/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-i1e7bP-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
# ...
building 'PIL._imagingtk' extension
creating build/temp.linux-x86_64-2.7/Tk
Building using 4 processes
gcc -pthread -B /home/albert/miniconda2/envs/cuckoo/compiler_compat -Wl,--sysroot=/ -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip-build-s5clPe/pillow/libImaging -I/home/albert/miniconda2/envs/cuckoo/include -I/usr/local/include -I/usr/include -I/home/albert/miniconda2/envs/cuckoo/include/python2.7 -I/usr/include/x86_64-linux-gnu -c _imagingtk.c -o build/temp.linux-x86_64-2.7/_imagingtk.o
gcc -pthread -B /home/albert/miniconda2/envs/cuckoo/compiler_compat -Wl,--sysroot=/ -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip-build-s5clPe/pillow/libImaging -I/home/albert/miniconda2/envs/cuckoo/include -I/usr/local/include -I/usr/include -I/home/albert/miniconda2/envs/cuckoo/include/python2.7 -I/usr/include/x86_64-linux-gnu -c Tk/tkImaging.c -o build/temp.linux-x86_64-2.7/Tk/tkImaging.o
In file included from Tk/tkImaging.c:52:0:
/home/albert/miniconda2/envs/cuckoo/include/tk.h:96:25: fatal error: X11/Xlib.h: No such file or directory
compilation terminated.
In file included from _imagingtk.c:19:0:
/home/albert/miniconda2/envs/cuckoo/include/tk.h:96:25: fatal error: X11/Xlib.h: No such file or directory
compilation terminated.
gcc -pthread -shared -B /home/albert/miniconda2/envs/cuckoo/compiler_compat -L/home/albert/miniconda2/envs/cuckoo/lib -Wl,-rpath=/home/albert/miniconda2/envs/cuckoo/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-2.7/_imagingtk.o build/temp.linux-x86_64-2.7/Tk/tkImaging.o -L/home/albert/miniconda2/envs/cuckoo/lib -L/lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/local/lib -L/usr/lib -L/home/albert/miniconda2/envs/cuckoo/lib -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -ltk8.6 -lpython2.7 -o build/lib.linux-x86_64-2.7/PIL/_imagingtk.so
gcc: error: build/temp.linux-x86_64-2.7/_imagingtk.o: No such file or directory
gcc: error: build/temp.linux-x86_64-2.7/Tk/tkImaging.o: No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
Rolling back uninstall of Pillow
Command "/home/albert/miniconda2/envs/cuckoo/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-s5clPe/pillow/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-i1e7bP-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-s5clPe/pillow/

Repair Procedures

Google了相關訊息,發現Cuckoo的Github上也有相同的issue,當中有人提到stackoverflow上有解決方案
雖然問題看似不相關,但推測就是少安裝了依賴。使用以下命令把缺的依賴一次安裝完:

1
sudo apt-get install libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk

再次使用pip安裝cuckoo,就成功了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
(cuckoo) albert@zhuang-pc:~$ pip install cuckoo
Collecting cuckoo
Requirement already satisfied: unicorn==1.0.1 in ./miniconda2/envs/cuckoo/lib/python2.7/site-packages (from cuckoo)
# ...
Collecting pycparser (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography>=1.3.4; extra == "security"->requests[security]==2.13.0; sys_platform == "linux2"->cuckoo)
Building wheels for collected packages: pillow
Running setup.py bdist_wheel for pillow ... done
Stored in directory: /home/albert/.cache/pip/wheels/88/2d/ce/3ff4ae4e2b8600d1bde1cbde5dfcc6d8770222c38348fe9139
Successfully built pillow
Installing collected packages: pillow, peepdf, olefile, python-magic, sflock, scapy, pymongo, idna, pycparser, cffi, enum34, asn1crypto, ipaddress, cryptography, pyOpenSSL, requests, pyelftools, yara-python, python-dateutil, functools32, jsonschema, pymisp, pefile2, cuckoo
Found existing installation: Pillow 4.3.0
Uninstalling Pillow-4.3.0:
Successfully uninstalled Pillow-4.3.0
Found existing installation: olefile 0.44
Uninstalling olefile-0.44:
Successfully uninstalled olefile-0.44
Successfully installed asn1crypto-0.24.0 cffi-1.11.2 cryptography-2.1.4 cuckoo-2.0.5.2 enum34-1.1.6 functools32-3.2.3.post2 idna-2.6 ipaddress-1.0.19 jsonschema-2.6.0 olefile-0.43 peepdf-0.3.6 pefile2-1.2.11 pillow-3.2.0 pyOpenSSL-17.5.0 pycparser-2.18 pyelftools-0.24 pymisp-2.4.54 pymongo-3.0.3 python-dateutil-2.4.2 python-magic-0.4.12 requests-2.13.0 scapy-2.3.2 sflock-0.2.17 yara-python-3.6.3