Closed vnt1537 closed 4 years ago
Hi, you probably forgot to add the k4a lib to the path. Check the readme for specific windows instructions. Can you show the command you used to install with pip?
Thank you for the answer. Can you please tell me to which path do we need to add this k4alib? I added it to the folder where my build for k4aviewer is. I tried using sudo pip install pyk4a sudo pip3 install pyk4a And even sudo -H pip3 install pyk4a
pip3 usually refers to pip on recent systems. python 2 is not supported for this library.
Please read the readme. You need to specify the path to the pip command.
I will close as this is a problem with your management of your windows environment. I will continue to answer your questions in this thread.
The issue is solved thank you.
Hi! I am facing a similar issue with pyk4a installation. Here is what I use:
ERROR: Command errored out with exit status 1: 'c:\users\krr\appdata\local\programs\python\python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\krr\AppData\Local\Temp\pip-install-zeusr1m1\pyk4a\setup.py'"'"'; file='"'"'C:\Users\krr\AppData\Local\Temp\pip-install-zeusr1m1\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 'C:\Users\krr\AppData\Local\Temp\pip-record-zoku34ab\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\krr\appdata\local\programs\python\python38-32\Include\pyk4a' Check the logs for full command output.
I have also tried using this path: C:\Program Files\Azure Kinect SDK v1.4.1\sdk\windows-desktop\amd64\release\bin>
And also this command: pip install pyk4a --global-option=build_ext --global-option="-IC:\Program Files\Azure Kinect SDK v1.2.0\sdk\include" --global-option="-LC:\Program Files\Azure Kinect SDK v1.2.0\sdk\windows-desktop\amd64\release\lib"
Any combination of the above two paths and commands still gives similar error. Could you please help me with this? I am sorry if my question is too naive or dumb. I am new to coding and kinect environments.
fatal error C1083: Cannot open include file: 'k4a/k4a.h': No such file or directory
is the error. You need to specify the path to k4a.h file by telling the compiler where they are. Usually compilers have a -I
option to specify directories to include.
pip install pyk4a
this will not work unless the includes (-I
) and libraries (-L
) are somehow given to the compiler. Which is why we need to specify their paths by adding options with --global-option
.
For the second command you used, I guess you didn't notice you were including directories of a k4a SDK v1.2.0 while you seem to have v1.4.1 installed.
Try this instead:
pip install pyk4a --global-option=build_ext --global-option="-IC:\Program Files\Azure Kinect SDK v1.4.1\sdk\include" --global-option="-LC:\Program Files\Azure Kinect SDK v1.4.1\sdk\windows-desktop\amd64\release\lib"
You should make sure this path exists in your system. Otherwise modify it to fit your k4a SDK install.
Hopefully this helps solve your problem. Sorry I am not a windows user and do not know any simple alternatives to this.
Thank you very much! This worked!
When I run the following command, I get an error:
from pyk4a import PyK4A
Traceback (most recent call last):
File "
Here is the link to the pyk4a module: https://github.com/etiennedub/pyk4a
Hi @kramakr4! did you resolve this issue? I have all of the paths in the env of windows, and after the install was successful i also get
import k4a_module
ImportError: DLL load failed while importing k4a_module: The specified module could not be found.
Do you have any suggestions?
@zapaishchykova sorry I never saw this. Did you manage to make it work?
@lpasselin oh yes, a bit of manipulation with paths and it worked!
@zapaishchykova What was the trick? I'm getting the same problem, and can't seem to find the right path to add.
@dmorris0
Thanks -- but unfortunately adding that line to my path and restarting my terminal doesn't work for me. Still get the error:
>>> from pyk4a import PyK4A
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\morri\Source\envs\cv\lib\site-packages\pyk4a\__init__.py", line 1, in <module>
import k4a_module
ImportError: DLL load failed while importing k4a_module: The specified module could not be found.
@dmorris0 can you show me the contents of your \release\bin?
Here is: C:\Program Files\Azure Kinect SDK v1.4.1\sdk\windows-desktop\amd64\release\bin
Do you specify in python path of the module?
import sys
sys.path.insert(1, '../pyKinectAzure/')
import numpy as np
from pyKinectAzure import pyKinectAzure,_k4a, postProcessing
import cv2
import time
import os
paths = []
# Path to the module
modulePath = r'C:\Program Files\Azure Kinect SDK v1.4.1\sdk\windows-desktop\amd64\release\bin'
if __name__ == "__main__":
# Initialize the library with the path containing the module
pyK4A = pyKinectAzure(modulePath)
# Open device
num_connected_devices = pyK4A.device_get_installed_count()
print("[LOG]: Number of connected devices ",num_connected_devices)
Ah interesting. I am trying to find out where your pyKinectAzure
folder came from. That's not in the pyk4a
repo as far as I can tell nor in the Azure Kinect SDK.
It should be this one https://github.com/ibaiGorordo/pyKinectAzure
I see -- that looks like a very nice repo. Perhaps if I get that one working it will solve my module import problem? But I also discovered that Open3D can read directly from the Kinect, and I got that up and running very easily. I might just go with Open3D unless this repo has advantages. Thanks for your help @zapaishchykova
@dmorris0 , please check this: https://github.com/etiennedub/pyk4a/issues/117#issuecomment-816801446
@shagren that looks exactly like what I need, but I run it and I get the same module error.
I had the same problem, but I solved applying #117 The solution given by @shagren was very useful. The steps applied were:
##############################
############################## import sys import os from path import Path
def _add_dll_directory(path: Path): from ctypes import c_wchar_p, windll # type: ignore from ctypes.wintypes import DWORD AddDllDirectory = windll.kernel32.AddDllDirectory AddDllDirectory.restype = DWORD AddDllDirectory.argtypes = [c_wchar_p] AddDllDirectory(str(path))
def kinect(): if sys.platform != "win32": return env_path = os.getenv("KINECT_LIBS", None) if env_path: candidate = Path(env_path) dll = candidate / "k4a.dll" if dll.exists(): _add_dll_directory(candidate) return
program_files = Path("C:\\Program Files\\")
for dir in sorted(program_files.glob("Azure Kinect SDK v*"), reverse=True):
candidate = dir / "sdk" / "windows-desktop" / "amd64" / "release" / "bin"
dll = candidate / "k4a.dll"
if dll.exists():
_add_dll_directory(candidate)
return
#############################
############################# import helper_path as hp
hp.kinect() from pyk4a import PyK4A from matplotlib import pyplot as plt
k4a = PyK4A() k4a.start()
capture = k4a.get_capture() img_color = capture.color img_depth = capture.depth img_ir = capture.ir
fig = plt.figure(1) plt.subplot(131) plt.imshow(img_depth) plt.title("DEPTH")
plt.subplot(132) plt.imshow(img_ir) plt.title("IR")
plt.subplot(133) plt.imshow(img_color[:, :, 2::-1]) # BGRA to RGB plt.show()
This problem is fixed in the dev. The next version will solve these windows install issues.
Thanks @lpasselin !!! my respects and congratulations for the great work!!
Thank @shagren!
In windows: adding C:\Program Files\Azure Kinect SDK v1.4.1\sdk\windows-desktop\amd64\release\bin
to the PATH env var (via edit envinronment variables
) solved it for me
First of all thank you for this repo. I am currently working on Nvidia Xavier and I receive the following error:
The error I receive is :
Collecting pyk4a Downloading https://files.pythonhosted.org/packages/ab/95/39fc624670d1f2c303e8db27b92a8d391085bcdb654004fcba0a43f41e7a/pyk4a-0.3.tar.gz Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from pyk4a) Building wheels for collected packages: pyk4a Running setup.py bdist_wheel for pyk4a ... error Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-2pf4lz14/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/tmp0xd5qmq2pip-wheel- --python-tag cp36: running bdist_wheel running build running build_py creating build creating build/lib.linux-aarch64-3.6 creating build/lib.linux-aarch64-3.6/pyk4a copying pyk4a/pyk4a.py -> build/lib.linux-aarch64-3.6/pyk4a copying pyk4a/config.py -> build/lib.linux-aarch64-3.6/pyk4a copying pyk4a/init.py -> build/lib.linux-aarch64-3.6/pyk4a running build_ext building 'k4a_module' extension creating build/temp.linux-aarch64-3.6 creating build/temp.linux-aarch64-3.6/pyk4a aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/lib/python3/dist-packages/numpy/core/include -I/usr/include/python3.6m -c pyk4a/pyk4a.cpp -o build/temp.linux-aarch64-3.6/pyk4a/pyk4a.o In file included from /usr/lib/python3/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1809:0, from /usr/lib/python3/dist-packages/numpy/core/include/numpy/ndarrayobject.h:18, from /usr/lib/python3/dist-packages/numpy/core/include/numpy/arrayobject.h:4, from pyk4a/pyk4a.cpp:2: /usr/lib/python3/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 " \
pyk4a/pyk4a.cpp:4:10: fatal error: k4a/k4a.h: No such file or directory
include <k4a/k4a.h>
compilation terminated. error: command 'aarch64-linux-gnu-gcc' failed with exit status 1
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 Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-2pf4lz14/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-t0682us4-record/install-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build creating build/lib.linux-aarch64-3.6 creating build/lib.linux-aarch64-3.6/pyk4a copying pyk4a/pyk4a.py -> build/lib.linux-aarch64-3.6/pyk4a copying pyk4a/config.py -> build/lib.linux-aarch64-3.6/pyk4a copying pyk4a/init.py -> build/lib.linux-aarch64-3.6/pyk4a running build_ext building 'k4a_module' extension creating build/temp.linux-aarch64-3.6 creating build/temp.linux-aarch64-3.6/pyk4a aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/lib/python3/dist-packages/numpy/core/include -I/usr/include/python3.6m -c pyk4a/pyk4a.cpp -o build/temp.linux-aarch64-3.6/pyk4a/pyk4a.o In file included from /usr/lib/python3/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1809:0, from /usr/lib/python3/dist-packages/numpy/core/include/numpy/ndarrayobject.h:18, from /usr/lib/python3/dist-packages/numpy/core/include/numpy/arrayobject.h:4, from pyk4a/pyk4a.cpp:2: /usr/lib/python3/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 " \
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-build-2pf4lz14/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-t0682us4-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-2pf4lz14/pyk4a/