Problem installing mtools

I am trying to get mtools working on the vagrant database instance for this course and am having problems doing so. Given that this course is not about vagrant or python, and is using a rather old version of MongoDB, I was wondering if might be able to get some guidance on how to get this done so that I may continue with the course. Thanks.

Here are my steps so far:

Note that MongoDB version v3.2.22 and Python 2.7 versions are installed.

  1. sudo apt-get install python-pip

  2. sudo pip install “mtools==1.5.1” // used 1.5.1 because it is compatible with Mongo 3.2

  3. mlaunch // results in the following error:

Traceback (most recent call last):
File “/usr/local/bin/mlaunch”, line 7, in
from mtools.mlaunch.mlaunch import main
File “/usr/local/lib/python2.7/dist-packages/mtools/mlaunch/mlaunch.py”, line 20, in
import psutil
ImportError: No module named psutil

I then tried to install module psutil with:

  1. sudo pip install psutil // which results in the following output and error:

Downloading/unpacking psutil
Downloading psutil-5.6.3.tar.gz (435kB): 435kB downloaded
Running setup.py (path:/tmp/pip_build_root/psutil/setup.py) egg_info for package psutil
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: ‘python_requires’
warnings.warn(msg)

Installing collected packages: psutil
Running setup.py install for psutil
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: ‘python_requires’
warnings.warn(msg)
building ‘psutil._psutil_linux’ extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=563 -DPSUTIL_LINUX=1 -I/usr/include/python2.7 -c psutil/_psutil_common.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_common.o
psutil/_psutil_common.c:9:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1
Complete output from command /usr/bin/python -c “import setuptools, tokenize;file=’/tmp/pip_build_root/psutil/setup.py’;exec(compile(getattr(tokenize, ‘open’, open)(file).read().replace(’\r\n’, ‘\n’), file, ‘exec’))” install --record /tmp/pip-2l0nNv-record/install-record.txt --single-version-externally-managed --compile:
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: ‘python_requires’

warnings.warn(msg)

running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.7

creating build/lib.linux-x86_64-2.7/psutil

copying psutil/_psposix.py -> build/lib.linux-x86_64-2.7/psutil

copying psutil/_psaix.py -> build/lib.linux-x86_64-2.7/psutil

copying psutil/_pssunos.py -> build/lib.linux-x86_64-2.7/psutil

copying psutil/_pswindows.py -> build/lib.linux-x86_64-2.7/psutil

copying psutil/_compat.py -> build/lib.linux-x86_64-2.7/psutil

copying psutil/_pslinux.py -> build/lib.linux-x86_64-2.7/psutil

copying psutil/_psosx.py -> build/lib.linux-x86_64-2.7/psutil

copying psutil/_psbsd.py -> build/lib.linux-x86_64-2.7/psutil

copying psutil/init.py -> build/lib.linux-x86_64-2.7/psutil

copying psutil/_common.py -> build/lib.linux-x86_64-2.7/psutil

creating build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/test_aix.py -> build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/test_posix.py -> build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/runner.py -> build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/test_memory_leaks.py -> build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/test_osx.py -> build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/test_unicode.py -> build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/test_system.py -> build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/init.py -> build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/test_process.py -> build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/test_sunos.py -> build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/test_connections.py -> build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/test_misc.py -> build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/test_windows.py -> build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/test_contracts.py -> build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/main.py -> build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/test_bsd.py -> build/lib.linux-x86_64-2.7/psutil/tests

copying psutil/tests/test_linux.py -> build/lib.linux-x86_64-2.7/psutil/tests

running build_ext

building ‘psutil._psutil_linux’ extension

creating build/temp.linux-x86_64-2.7

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

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=563 -DPSUTIL_LINUX=1 -I/usr/include/python2.7 -c psutil/_psutil_common.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_common.o

psutil/_psutil_common.c:9:20: fatal error: Python.h: No such file or directory

#include <Python.h>

                ^

compilation terminated.

error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1

Thanks a lot for sharing the information. Give me some time, I am looking into it.

Kanika

Hi @Rick_47429,

Meanwhile, M312: Diagnostics and Debugging course provides whole lot more information and vagrant environment especially for mtools.

If you can go ahead and try this. As it is very difficult to get mtools setup on old environment. Our team is working on updating a new version of M310 course, but that will take some time.

Kanika

@Rick_47429 I’m halfway through Ch2 and needed Mtools to quickly spin up replica sets. Spent half an hour looking into it, ended up ditching the idea as there were too many dependencies.

@kanikasingla - I’m already taking m310 and m220js at the moment. I’ll be happy to use the mtools instructions in m312, but can you first verify whether they will work within the vagrant database instance in m310? I’m kind of tapped out at the moment in terms of time. Was planning to do the m312 course later. Thanks!!

@007_jb - thanks for your feedback. What are you doing instead? Just creating them by hand or with a script?

Yeah! Config files and running each one instead of using mongo options (as per video). I create the primary first, make sure all the params are fine, then setup the secondaries based on the primary.

As you know, the mongo options are sometimes a bit different from the config YAML options so it’s good practice for me as it represents more of a real life scenario.

I used mtools in M312 Diagnostics and (I think) M103 Cluster Admin.

@007_jb - got it. thanks for your feedback. Agreed, doing it by hand does yield more practice.

1 Like