[PYTHON] I get an error when trying to install maec 4.0.1.0 with pip

When I tried to set up the Cuckoo Sandbox and tried to install maec version 4.0.1.0 with pip, I got an error, so I investigated it. It's a result of trial and error, so I think there is definitely another correct method, so please let me know. (※I added.)

environment

error contents

$ sudo pip install maec==4.0.1.0
Downloading/unpacking maec==4.0.1.0
  Downloading maec-4.0.1.0.tar.gz (114kB): 114kB downloaded
  Running setup.py (path:/tmp/pip_build_root/maec/setup.py) egg_info for package maec
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_root/maec/setup.py", line 1, in <module>
        import maec
      File "maec/__init__.py", line 6, in <module>
        import bindings.maec_bundle as bundle_binding
      File "maec/bindings/maec_bundle.py", line 12, in <module>
        from cybox.bindings import cybox_core
    ImportError: No module named cybox.bindings
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_root/maec/setup.py", line 1, in <module>

    import maec

  File "maec/__init__.py", line 6, in <module>

    import bindings.maec_bundle as bundle_binding

  File "maec/bindings/maec_bundle.py", line 12, in <module>

    from cybox.bindings import cybox_core

ImportError: No module named cybox.bindings

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/maec
Storing debug log for failure in /home/vagrant/.pip/pip.log

I get an error like this.

cybox installation

Looking at the error content, it seems that I am angry that there is no cybox, so I will insert cybox.

$ sudo pip install cybox

(Omitted)

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/src

creating build/temp.linux-x86_64-2.7/src/lxml

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/tmp/pip_build_root/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w

x86_64-linux-gnu-gcc: internal compiler error: Killed (program cc1)

Please submit a full bug report,

with preprocessed source if appropriate.

See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 4

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-unrw2N-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/lxml
Storing debug log for failure in /home/vagrant/.pip/pip.log

I get an error. I'm going to get an error one after another and it's going to break my heart, but let's take a look at the official documentation. http://cybox.readthedocs.org/en/latest/installation.html There seems to be some libraries that depend on it. If you put it in, it seems to be solved.

$ sudo apt-get install libxml2-dev libxslt1-dev zlib1g-dev

And install again.

$ sudo pip install cybox

(Omitted)

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/src

creating build/temp.linux-x86_64-2.7/src/lxml

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/tmp/pip_build_root/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w

x86_64-linux-gnu-gcc: internal compiler error: Killed (program cc1)

Please submit a full bug report,

with preprocessed source if appropriate.

See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 4

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-unrw2N-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/lxml
Storing debug log for failure in /home/vagrant/.pip/pip.log

The error hasn't changed! Apparently lxml doesn't seem to work, so I'll try installing lxml this time.

lxml installation

I think I can install it with pip, so I'll try it.

$ sudo pip install lxml
(Omitted)
creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/src

creating build/temp.linux-x86_64-2.7/src/lxml

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/tmp/pip_build_root/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w

x86_64-linux-gnu-gcc: internal compiler error: Killed (program cc1)

Please submit a full bug report,

with preprocessed source if appropriate.

See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 4

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-7X8_bC-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/lxml
Storing debug log for failure in /home/vagrant/.pip/pip.log

I get the same error, so it seems that lxml was the cause. Looking at the official documentation (http://lxml.de/installation.html), there was a way to turn off C optimization to speed up the build, so give it a try just in case. ..

vagrant@vagrant-ubuntu-trusty-64:~$ sudo CFLAGS="-O0" pip install lxml
Downloading/unpacking lxml
  Downloading lxml-3.4.0.tar.gz (3.5MB): 3.5MB downloaded
  Running setup.py (path:/tmp/pip_build_root/lxml/setup.py) egg_info for package lxml
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    Building lxml version 3.4.0.
    Building without Cython.
    Using build configuration of libxslt 1.1.28

    warning: no previously-included files found matching '*.py'
Installing collected packages: lxml
  Running setup.py install for lxml
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    Building lxml version 3.4.0.
    Building without Cython.
    Using build configuration of libxslt 1.1.28
    building 'lxml.etree' extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -O0 -fPIC -I/usr/include/libxml2 -I/tmp/pip_build_root/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -w
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -O0 build/temp.linux-x86_64-2.7/src/lxml/lxml.etree.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-x86_64-2.7/lxml/etree.so
    building 'lxml.objectify' extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -O0 -fPIC -I/usr/include/libxml2 -I/tmp/pip_build_root/lxml/src/lxml/includes -I/usr/include/python2.7 -c src/lxml/lxml.objectify.c -o build/temp.linux-x86_64-2.7/src/lxml/lxml.objectify.o -w
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -O0 build/temp.linux-x86_64-2.7/src/lxml/lxml.objectify.o -lxslt -lexslt -lxml2 -lz -lm -o build/lib.linux-x86_64-2.7/lxml/objectify.so

Successfully installed lxml
Cleaning up...

It looks like it's good. .. Was it moss at the point of optimization? I'd like to find out more, but I'm tired, so please someone.

Install cybox (re-challenge)

$ sudo pip install cybox
Requirement already satisfied (use --upgrade to upgrade): cybox in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): lxml>=2.3 in /usr/local/lib/python2.7/dist-packages (from cybox)
Downloading/unpacking python-dateutil (from cybox)
  Downloading python-dateutil-2.2.tar.gz (259kB): 259kB downloaded
  Running setup.py (path:/tmp/pip_build_root/python-dateutil/setup.py) egg_info for package python-dateutil

Requirement already satisfied (use --upgrade to upgrade): six in /usr/lib/python2.7/dist-packages (from python-dateutil->cybox)
Installing collected packages: python-dateutil
  Running setup.py install for python-dateutil

Successfully installed python-dateutil
Cleaning up...

I finally got it.

maec installation (re-challenge)

You should be able to go with this!

$ sudo pip install maec==4.0.1.0
Downloading/unpacking maec==4.0.1.0
  Downloading maec-4.0.1.0.tar.gz (114kB): 114kB downloaded
  Running setup.py (path:/tmp/pip_build_root/maec/setup.py) egg_info for package maec
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_root/maec/setup.py", line 1, in <module>
        import maec
      File "maec/__init__.py", line 6, in <module>
        import bindings.maec_bundle as bundle_binding
      File "maec/bindings/maec_bundle.py", line 5424, in <module>
        'Relationships': cybox_core.RelationshipsType,
    AttributeError: 'module' object has no attribute 'RelationshipsType'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_root/maec/setup.py", line 1, in <module>

    import maec

  File "maec/__init__.py", line 6, in <module>

    import bindings.maec_bundle as bundle_binding

  File "maec/bindings/maec_bundle.py", line 5424, in <module>

    'Relationships': cybox_core.RelationshipsType,

AttributeError: 'module' object has no attribute 'RelationshipsType'

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/maec
Storing debug log for failure in /home/vagrant/.pip/pip.log

Different error. .. It's impossible anymore. .. When I encouraged myself and managed to find out, it seems that the version of cybox is different. It is said that v2.0.1.4 should be dropped.

Install cybox (Challenge again)

$ wget https://github.com/CybOXProject/python-cybox/archive/v2.0.1.4.tar.gz
$ tar zxvf v2.0.1.4.tar.gz
$ cd python-cybox-2.0.1.4/
$ sudo python setup.py install
(Omitted)
Installed /usr/local/lib/python2.7/dist-packages/cybox-2.0.1.4-py2.7.egg
Processing dependencies for cybox==2.0.1.4
Searching for python-dateutil==2.2
Best match: python-dateutil 2.2
Processing python_dateutil-2.2-py2.7.egg
python-dateutil 2.2 is already the active version in easy-install.pth

Using /usr/local/lib/python2.7/dist-packages/python_dateutil-2.2-py2.7.egg
Searching for lxml==3.4.0
Best match: lxml 3.4.0
Processing lxml-3.4.0-py2.7-linux-x86_64.egg
lxml 3.4.0 is already the active version in easy-install.pth

Using /usr/local/lib/python2.7/dist-packages/lxml-3.4.0-py2.7-linux-x86_64.egg
Searching for six==1.5.2
Best match: six 1.5.2
six 1.5.2 is already the active version in easy-install.pth

Using /usr/lib/python2.7/dist-packages
Finished processing dependencies for cybox==2.0.1.4

Install maec (again challenge)

$ sudo pip install maec==4.0.1.0
Downloading/unpacking maec==4.0.1.0
  Downloading maec-4.0.1.0.tar.gz (114kB): 114kB downloaded
  Running setup.py (path:/tmp/pip_build_root/maec/setup.py) egg_info for package maec

Requirement already satisfied (use --upgrade to upgrade): lxml>=2.3 in /usr/local/lib/python2.7/dist-packages/lxml-3.4.0-py2.7-linux-x86_64.egg (from maec==4.0.1.0)
Requirement already satisfied (use --upgrade to upgrade): cybox>=2.0.1.0,<2.0.2.0 in /usr/local/lib/python2.7/dist-packages/cybox-2.0.1.4-py2.7.egg (from maec==4.0.1.0)
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /usr/local/lib/python2.7/dist-packages/python_dateutil-2.2-py2.7.egg (from cybox>=2.0.1.0,<2.0.2.0->maec==4.0.1.0)
Requirement already satisfied (use --upgrade to upgrade): six in /usr/lib/python2.7/dist-packages (from python-dateutil->cybox>=2.0.1.0,<2.0.2.0->maec==4.0.1.0)
Installing collected packages: maec
  Running setup.py install for maec

Successfully installed maec
Cleaning up...

Oh. .. I was finally able to install it. .. That's why I finally got it!

Summary

I wrote the process of trial and error for a long time, but in the end it is in the following order.

  1. Insert lxml
  2. Insert cybox (v2.0.1.4)
  3. Insert maec (4.0.1.0)
#Put the libraries that lxml depends on
$ sudo apt-get install libxml2-dev libxslt1-dev zlib1g-dev
#Insert lxml
$ sudo CFLAGS="-O0" pip install lxml
#Insert cybox
$ wget https://github.com/CybOXProject/python-cybox/archive/v2.0.1.4.tar.gz
$ tar zxvf v2.0.1.4.tar.gz
$ cd python-cybox-2.0.1.4/
$ sudo python setup.py install
#Insert maec
$ sudo pip install maec==4.0.1.0

Postscript

lxml seems to be put in with apt-get.

$ sudo apt-get install python-lxml

If you use this to modify the above command,

#python-Maybe just lxml
$ sudo apt-get install libxml2-dev libxslt1-dev zlib1g-dev python-lxml
#Insert cybox
$ wget https://github.com/CybOXProject/python-cybox/archive/v2.0.1.4.tar.gz
$ tar zxvf v2.0.1.4.tar.gz
$ cd python-cybox-2.0.1.4/
$ sudo python setup.py install
#Insert maec
$ sudo pip install maec==4.0.1.0

It has been greatly simplified.

Recommended Posts

I get an error when trying to install maec 4.0.1.0 with pip
Workaround if you get an error when trying to install PySide with pip
When I get an error with PyInstaller
What to do if you get an Undefined error when trying to use pip with pyenv
I got an error when trying to install Xgboost and its solution
I get an error when trying meinheld + WebSocket + mongodb
A memorandum when an error occurs with pip install
I get [Error 2055] when trying to connect to MySQL on Heroku
When I try to install mysqlclient with Django, I get error: command'gcc' failed with exit status 1.
I got an error when pip install pandas on Mac, so I dealt with it
I get an error with import pandas.
I want to pip install with PythonAnywhere
I got an error when pip install tweepy on macOS Sierra, so I dealt with it
Error with pip install
I got an error when saving with OpenCV
I get an error with all yum commands
Error when trying to install psycopg2 in Python
I got an SSL related error with pip install, so I solved it
I get a UnicodeDecodeError when trying to connect to oracle with python sqlalchemy
What to do if you get an error when trying to load mnist
When I try to upgrade pip, I get an infinite loop after failing to upgrade
I got an error when trying to run Hello World in Go language
When moss with pip install
An error occurs when trying to import scikit-learn after connecting to Oracle with SQLAlchemy
I get an error when I put opencv in pyautoGUI
What to do if you get an error when installing python with pyenv
I got an error when using Tensorboard with Pytorch
What to do if you get an OpenSSL error when installing Python 2 with pyenv
For those who are in trouble with an error when pip install xg boost
I want to get an error message in Japanese with django Password Change Form
What to do if you get an Import Error when importing matplotlib with Jupyter
I get an error when I try to raise Python to 3 series using pyenv on Catalina
What to do when an error occurs with import _ssl
I have libncurses but get angry with pip install readline
How to install mysql-connector with pip3
Proxy error when running "pip install"
[Solution] When I try to connect to CloudSQL with GAE, I get an ImportError only when using dev_appserver.
A memorandum when I tried to get it automatically with selenium
# Solution when pip install gives an error when using Anaconda on Windows 10
[Beanstalk] What to do when an error occurs with import uuid
What to do if you get a UnicodeDecodeError with pip install
SSL certificate related with pip install? Error
I tried to get started with Hy
I was addicted to pip install mysqlclient
I get an OS Error: [Errno 8] Exec format error when running a Flask application with a python command
I can't install the package with pip.
EC2 / Amazon Linux2: What to do if you get an "unable to execute'gcc': No such file or directory" error with pip install
I want to get angry with my mom when my memory is tight
A story I was addicted to trying to get a video url with tweepy
What to do if pyenv install does not proceed with an error
What to do if an error occurs when importing numpy with VScode
What to do if you get an error when installing Dlib (Ubuntu)
[OSX] [pyenv] What to do when an SSL error occurs in pip
[AWS] How to deal with WordPress "An error occurred when cropping an image."
I got stuck trying to install various things with Mac El captain pip, so make a note
Error when installing a module with Python pip
I can't install Dask with pip on Ubuntu
How to deal with errors when hitting pip ②
I tried to get an image by scraping
I wanted to install Python 3.4.3 with Homebrew + pyenv
I want to be an OREMO with setParam!