question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to install on Linux

See original GitHub issue

At first: Thanks for making this repo available!

I’m currently unable to install pyk4a on linux (Mint 19.1 which is based on Ubuntu 18.04).

Problem: It seems that the compiler can’t find the k4a.h.

pyk4a/pyk4a.cpp:4:10: fatal error: k4a/k4a.h: No such file or directory
     #include <k4a/k4a.h>
              ^~~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1

What i did:

  1. Installed the Azure-Kinect-Sensor-SDK 1.4.0 according to the instruction.
  2. Tested the ./bin/k4aviewer --> worked
  3. Added the LD_LIBRARY_PATH (At least I think I did…)
(Kinect_env) nixi@nixis-laptop:~/Projects/Azure_Kinect/pyk4a/example$ export LD_LIBRARY_PATH=/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/include/:/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/build/src/sdk/include/
(Kinect_env) nixi@nixis-laptop:~/Projects/Azure_Kinect/pyk4a/example$ echo $LD_LIBRARY_PATH
/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/include/:/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/build/src/sdk/include/
  1. run: pip install pyk4a
(Kinect_env) nixi@nixis-laptop:~/Projects/Azure_Kinect/pyk4a/example$ pip install pyk4a
Collecting pyk4a
  Using cached pyk4a-0.3.tar.gz (6.9 kB)
Requirement already satisfied: numpy in /home/nixi/anaconda3/envs/Kinect_env/lib/python3.8/site-packages (from pyk4a) (1.18.2)
Building wheels for collected packages: pyk4a
  Building wheel for pyk4a (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/nixi/anaconda3/envs/Kinect_env/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-12goisa7/pyk4a/setup.py'"'"'; __file__='"'"'/tmp/pip-install-12goisa7/pyk4a/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-457cvchg
       cwd: /tmp/pip-install-12goisa7/pyk4a/
  Complete output (27 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.8
  creating build/lib.linux-x86_64-3.8/pyk4a
  copying pyk4a/pyk4a.py -> build/lib.linux-x86_64-3.8/pyk4a
  copying pyk4a/config.py -> build/lib.linux-x86_64-3.8/pyk4a
  copying pyk4a/__init__.py -> build/lib.linux-x86_64-3.8/pyk4a
  running build_ext
  building 'k4a_module' extension
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/pyk4a
  gcc -pthread -B /home/nixi/anaconda3/envs/Kinect_env/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/nixi/anaconda3/envs/Kinect_env/lib/python3.8/site-packages/numpy/core/include -I/home/nixi/anaconda3/envs/Kinect_env/include/python3.8 -c pyk4a/pyk4a.cpp -o build/temp.linux-x86_64-3.8/pyk4a/pyk4a.o
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  In file included from /home/nixi/anaconda3/envs/Kinect_env/lib/python3.8/site-packages/numpy/core/include/numpy/ndarraytypes.h:1832:0,
                   from /home/nixi/anaconda3/envs/Kinect_env/lib/python3.8/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                   from /home/nixi/anaconda3/envs/Kinect_env/lib/python3.8/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                   from pyk4a/pyk4a.cpp:2:
  /home/nixi/anaconda3/envs/Kinect_env/lib/python3.8/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
   #warning "Using deprecated NumPy API, disable it with " \
    ^~~~~~~
  pyk4a/pyk4a.cpp:4:10: fatal error: k4a/k4a.h: No such file or directory
   #include <k4a/k4a.h>
            ^~~~~~~~~~~
  compilation terminated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pyk4a
  Running setup.py clean for pyk4a
Failed to build pyk4a
Installing collected packages: pyk4a
    Running setup.py install for pyk4a ... error
    ERROR: Command errored out with exit status 1:
     command: /home/nixi/anaconda3/envs/Kinect_env/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-12goisa7/pyk4a/setup.py'"'"'; __file__='"'"'/tmp/pip-install-12goisa7/pyk4a/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-record-asgtfnnx/install-record.txt --single-version-externally-managed --compile --install-headers /home/nixi/anaconda3/envs/Kinect_env/include/python3.8/pyk4a
         cwd: /tmp/pip-install-12goisa7/pyk4a/
    Complete output (27 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.8
    creating build/lib.linux-x86_64-3.8/pyk4a
    copying pyk4a/pyk4a.py -> build/lib.linux-x86_64-3.8/pyk4a
    copying pyk4a/config.py -> build/lib.linux-x86_64-3.8/pyk4a
    copying pyk4a/__init__.py -> build/lib.linux-x86_64-3.8/pyk4a
    running build_ext
    building 'k4a_module' extension
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/pyk4a
    gcc -pthread -B /home/nixi/anaconda3/envs/Kinect_env/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/nixi/anaconda3/envs/Kinect_env/lib/python3.8/site-packages/numpy/core/include -I/home/nixi/anaconda3/envs/Kinect_env/include/python3.8 -c pyk4a/pyk4a.cpp -o build/temp.linux-x86_64-3.8/pyk4a/pyk4a.o
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    In file included from /home/nixi/anaconda3/envs/Kinect_env/lib/python3.8/site-packages/numpy/core/include/numpy/ndarraytypes.h:1832:0,
                     from /home/nixi/anaconda3/envs/Kinect_env/lib/python3.8/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                     from /home/nixi/anaconda3/envs/Kinect_env/lib/python3.8/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                     from pyk4a/pyk4a.cpp:2:
    /home/nixi/anaconda3/envs/Kinect_env/lib/python3.8/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
     #warning "Using deprecated NumPy API, disable it with " \
      ^~~~~~~
    pyk4a/pyk4a.cpp:4:10: fatal error: k4a/k4a.h: No such file or directory
     #include <k4a/k4a.h>
              ^~~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/nixi/anaconda3/envs/Kinect_env/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-12goisa7/pyk4a/setup.py'"'"'; __file__='"'"'/tmp/pip-install-12goisa7/pyk4a/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-record-asgtfnnx/install-record.txt --single-version-externally-managed --compile --install-headers /home/nixi/anaconda3/envs/Kinect_env/include/python3.8/pyk4a Check the logs for full command output.
(Kinect_env) nixi@nixis-laptop:~/Projects/Azure_Kinect/pyk4a/example$ 

I think I didn’t add the LD_LIBRARY_PATH correctly.

5 . So I tryed the following as well:

(Kinect_env) nixi@nixis-laptop:~/Projects/Azure_Kinect/pyk4a/example$ sudo -H pip install --global-option build_ext --global-option -I/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/include/:/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/build/src/sdk/include/ --global-option -L/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/include/:/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/build/src/sdk/include/ pyk4a
[sudo] password for nixi:          
/usr/lib/python2.7/dist-packages/pip/commands/install.py:212: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
  cmdoptions.check_install_build_global(options)
Collecting pyk4a
  Using cached https://files.pythonhosted.org/packages/ab/95/39fc624670d1f2c303e8db27b92a8d391085bcdb654004fcba0a43f41e7a/pyk4a-0.3.tar.gz
Requirement already satisfied: numpy in /usr/lib/python2.7/dist-packages (from pyk4a)
Skipping bdist_wheel for pyk4a, due to binaries being disabled for it.
Installing collected packages: pyk4a
  Running setup.py install for pyk4a ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-hqYnRx/pyk4a/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" build_ext -I/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/include/:/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/build/src/sdk/include/ -L/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/include/:/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/build/src/sdk/include/ install --record /tmp/pip-8stf3r-record/install-record.txt --single-version-externally-managed --compile:
    running build_ext
    building 'k4a_module' extension
    creating build
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/pyk4a
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-5Z483E/python2.7-2.7.17=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/include/ -I/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/build/src/sdk/include/ -I/usr/include/python2.7 -c pyk4a/pyk4a.cpp -o build/temp.linux-x86_64-2.7/pyk4a/pyk4a.o
    In file included from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1809:0,
                     from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                     from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
                     from pyk4a/pyk4a.cpp:2:
    /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
     #warning "Using deprecated NumPy API, disable it by " \
      ^~~~~~~
    In file included from /usr/include/python2.7/Python.h:84:0,
                     from pyk4a/pyk4a.cpp:1:
    pyk4a/pyk4a.cpp: In function ‘int pyk4a_traverse(PyObject*, visitproc, void*)’:
    pyk4a/pyk4a.cpp:187:44: error: ‘PyModule_GetState’ was not declared in this scope
     #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
                                                ^
    /usr/include/python2.7/objimpl.h:341:13: note: in definition of macro ‘Py_VISIT’
             if (op) {                                                       \
                 ^~
    pyk4a/pyk4a.cpp:209:18: note: in expansion of macro ‘GETSTATE’
             Py_VISIT(GETSTATE(m)->error);
                      ^~~~~~~~
    pyk4a/pyk4a.cpp:187:44: note: suggested alternative: ‘PyModule_GetName’
     #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
                                                ^
    /usr/include/python2.7/objimpl.h:341:13: note: in definition of macro ‘Py_VISIT’
             if (op) {                                                       \
                 ^~
    pyk4a/pyk4a.cpp:209:18: note: in expansion of macro ‘GETSTATE’
             Py_VISIT(GETSTATE(m)->error);
                      ^~~~~~~~
    In file included from /usr/include/python2.7/Python.h:83:0,
                     from pyk4a/pyk4a.cpp:1:
    pyk4a/pyk4a.cpp: In function ‘int pyk4a_clear(PyObject*)’:
    pyk4a/pyk4a.cpp:187:44: error: ‘PyModule_GetState’ was not declared in this scope
     #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
                                                ^
    /usr/include/python2.7/object.h:816:13: note: in definition of macro ‘Py_CLEAR’
             if (op) {                               \
                 ^~
    pyk4a/pyk4a.cpp:215:18: note: in expansion of macro ‘GETSTATE’
             Py_CLEAR(GETSTATE(m)->error);
                      ^~~~~~~~
    pyk4a/pyk4a.cpp:187:44: note: suggested alternative: ‘PyModule_GetName’
     #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
                                                ^
    /usr/include/python2.7/object.h:816:13: note: in definition of macro ‘Py_CLEAR’
             if (op) {                               \
                 ^~
    pyk4a/pyk4a.cpp:215:18: note: in expansion of macro ‘GETSTATE’
             Py_CLEAR(GETSTATE(m)->error);
                      ^~~~~~~~
    pyk4a/pyk4a.cpp: At global scope:
    pyk4a/pyk4a.cpp:219:31: error: variable ‘PyModuleDef moduledef’ has initializer but incomplete type
         static struct PyModuleDef moduledef =
                                   ^~~~~~~~~
    pyk4a/pyk4a.cpp:221:9: error: ‘PyModuleDef_HEAD_INIT’ was not declared in this scope
             PyModuleDef_HEAD_INIT,
             ^~~~~~~~~~~~~~~~~~~~~
    pyk4a/pyk4a.cpp:221:9: note: suggested alternative: ‘PyObject_HEAD_INIT’
             PyModuleDef_HEAD_INIT,
             ^~~~~~~~~~~~~~~~~~~~~
             PyObject_HEAD_INIT
    pyk4a/pyk4a.cpp: In function ‘void PyInit_k4a_module()’:
    pyk4a/pyk4a.cpp:239:28: error: ‘PyModule_Create’ was not declared in this scope
             PyObject *module = PyModule_Create(&moduledef);
                                ^~~~~~~~~~~~~~~
    pyk4a/pyk4a.cpp:239:28: note: suggested alternative: ‘_PyModule_Clear’
             PyObject *module = PyModule_Create(&moduledef);
                                ^~~~~~~~~~~~~~~
                                _PyModule_Clear
    In file included from /usr/include/c++/7/cstddef:50:0,
                     from /home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/include/k4a/k4atypes.h:12,
                     from /home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/include/k4a/k4a.h:16,
                     from pyk4a/pyk4a.cpp:4:
    pyk4a/pyk4a.cpp:231:26: error: return-statement with a value, in function returning 'void' [-fpermissive]
     #define INITERROR return NULL
                              ^
    pyk4a/pyk4a.cpp:242:13: note: in expansion of macro ‘INITERROR’
                 INITERROR;
                 ^~~~~~~~~
    pyk4a/pyk4a.cpp:187:44: error: ‘PyModule_GetState’ was not declared in this scope
     #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
                                                ^
    pyk4a/pyk4a.cpp:243:35: note: in expansion of macro ‘GETSTATE’
             struct module_state *st = GETSTATE(module);
                                       ^~~~~~~~
    pyk4a/pyk4a.cpp:187:44: note: suggested alternative: ‘PyModule_GetName’
     #define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
                                                ^
    pyk4a/pyk4a.cpp:243:35: note: in expansion of macro ‘GETSTATE’
             struct module_state *st = GETSTATE(module);
                                       ^~~~~~~~
    pyk4a/pyk4a.cpp:245:72: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
             st->error = PyErr_NewException("pyk4a_module.Error", NULL, NULL);
                                                                            ^
    In file included from /usr/include/c++/7/cstddef:50:0,
                     from /home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/include/k4a/k4atypes.h:12,
                     from /home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/include/k4a/k4a.h:16,
                     from pyk4a/pyk4a.cpp:4:
    pyk4a/pyk4a.cpp:231:26: error: return-statement with a value, in function returning 'void' [-fpermissive]
     #define INITERROR return NULL
                              ^
    pyk4a/pyk4a.cpp:249:13: note: in expansion of macro ‘INITERROR’
                 INITERROR;
                 ^~~~~~~~~
    pyk4a/pyk4a.cpp:251:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
             return module;
                    ^~~~~~
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-hqYnRx/pyk4a/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" build_ext -I/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/include/:/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/build/src/sdk/include/ -L/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/include/:/home/nixi/Projects/Azure_Kinect/Azure-Kinect-Sensor-SDK/build/src/sdk/include/ install --record /tmp/pip-8stf3r-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-hqYnRx/pyk4a/
(Kinect_env) nixi@nixis-laptop:~/Projects/Azure_Kinect/pyk4a/example$ 

I did also run it as root, same outcome.

The same 5 steps I did on my Jetson Nano which has no Conda environment running, a different architecture and a linux system derived from Ubuntu. There the error massages are alike to the try above.

I would really appreciate help on that.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
omartin2010commented, Apr 14, 2020

if that helps, I have a dockerfile here that works with this… you may have to change it a bit because I was using prerelease code. It’s also not on a Nano but on a Jetson TX2. But essentially you’d have to change a few lines in the Dockerfile, AFAIK, to get that working. My image includes opencv & tensorflow, both of which work well with the k4a. Hope this helps… at least running it in Docker and maybe help troubleshoot your issue.

0reactions
neixlocommented, Apr 16, 2020

It’s working now!

I needed to add the …/bin path which contains libk4a.so.1.4 again to LD_LIBRARY_PATH. After installation it appeared to be empty.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I can't install Linux?
Do this: Under the Advanced startup, click Restart now. Select Troubleshoot > Advanced Options > UEFI Firmware settings and then Restart. In the ......
Read more >
Unable to install any programs - Unix & Linux Stack Exchange
Problem 1. apt-get is for downloading and installing packages from the Debian repositories. It is not for installing local .deb files.
Read more >
can't install any apps - Ask Ubuntu
Open a terminal by pressein Ctrl-Alt-T; run 'sudo apt update' and 'sudo apt upgrade' and update your question with the output of the...
Read more >
Can't install Linux with Windows 10? Here's what to do
Make sure you have enough space and check storage for errors · Create installation media again · Try booting into Linux from USB/DVD...
Read more >
Cannot install any linux operating system!!! - Tech Support Guy
With the new UEFI and secure boot features.......this is what happens. You need to change the BIOS settings to either UEFI and Legacy...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found