My goal is to use Anomalib on NVIDIA Jetson Nano B01 to detect anomaly from a frame. The frame input is from ArduCAM IMX519. The problem is that I can’t install Anomalib on NVIDIA Jetson Nano B01.
What I’ve tried:
- Install from GitHub repository
// create virtualenv
$ python3.8 -m virtualenv GoDataID_anomalib
$ . GoDataID_anomalib/bin/activate
$ git clone --branch abi3-linux-aarch64 https://github.com/mayeut/psutil.git
$ cd psutil
$ python -m pip install -e .
However, it throws error
(GoDataID_anomalib) werate-01@werate-01:~/psutil$ python -m pip install -e .
Obtaining file:///home/werate-01/psutil
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... done
Preparing editable metadata (pyproject.toml) ... done
Building wheels for collected packages: psutil
Building editable for psutil (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building editable for psutil (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [74 lines of output]
running editable_wheel
creating /tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil.egg-info
writing /tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil.egg-info/PKG-INFO
writing dependency_links to /tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil.egg-info/dependency_links.txt
writing requirements to /tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil.egg-info/requires.txt
writing top-level names to /tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil.egg-info/top_level.txt
writing manifest file '/tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil.egg-info/SOURCES.txt'
reading manifest file '/tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
adding license file 'LICENSE'
writing manifest file '/tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil.egg-info/SOURCES.txt'
creating '/tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil-5.9.5.dist-info'
creating /tmp/pip-wheel-yxj7qlte/.tmp-28hv6kcy/psutil-5.9.5.dist-info/WHEEL
running build_py
running build_ext
building 'psutil._psutil_linux' extension
creating /tmp/tmpzf6gr400.build-temp/psutil
aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID_T=4 -DPSUTIL_VERSION=595 -DPy_LIMITED_API=0x03060000 -DPSUTIL_LINUX=1 -I/home/werate-01/GoDataID_anomalib/include -I/usr/include/python3.8 -c psutil/_psutil_common.c -o /tmp/tmpzf6gr400.build-temp/psutil/_psutil_common.o
psutil/_psutil_common.c:9:10: fatal error: Python.h: No such file or directory
#include <Python.h>
^~~~~~~~~~
compilation terminated.
Traceback (most recent call last):
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/unixccompiler.py", line 186, in _compile
self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/ccompiler.py", line 1007, in spawn
spawn(cmd, dry_run=self.dry_run, **kwargs)
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/spawn.py", line 70, in spawn
raise DistutilsExecError(
distutils.errors.DistutilsExecError: command '/usr/bin/aarch64-linux-gnu-gcc' failed with exit code 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/command/editable_wheel.py", line 140, in run
self._create_wheel_file(bdist_wheel)
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/command/editable_wheel.py", line 330, in _create_wheel_file
files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp)
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/command/editable_wheel.py", line 261, in _run_build_commands
self._run_build_subcommands()
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/command/editable_wheel.py", line 288, in _run_build_subcommands
self.run_command(name)
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
self.distribution.run_command(command)
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 1213, in run_command
super().run_command(command)
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 84, in run
_build_ext.run(self)
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
self.build_extensions()
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/build_ext.py", line 468, in build_extensions
self._build_extensions_serial()
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/build_ext.py", line 494, in _build_extensions_serial
self.build_extension(ext)
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 246, in build_extension
_build_ext.build_extension(self, ext)
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/build_ext.py", line 549, in build_extension
objects = self.compiler.compile(
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/ccompiler.py", line 599, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/tmp/pip-build-env-fxswk_un/overlay/lib/python3.8/site-packages/setuptools/_distutils/unixccompiler.py", line 188, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command '/usr/bin/aarch64-linux-gnu-gcc' failed with exit code 1
error: Support for editable installs via PEP 660 was recently introduced
in `setuptools`. If you are seeing this error, please report to:
https://github.com/pypa/setuptools/issues
Meanwhile you can try the legacy behavior by setting an
environment variable and trying to install again:
SETUPTOOLS_ENABLE_FEATURES="legacy-editable"
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building editable for psutil
Failed to build psutil
ERROR: Could not build wheels for psutil, which is required to install pyproject.toml-based projects
[notice] A new release of pip available: 22.3.1 -> 23.0
[notice] To update, run: pip install --upgrade pip
Solution:
note: I have not tested it to inference.
# Install Python3.8
$ sudo apt-get update
$ sudo apt-get install python3.8
# Install pip on Python3.8
$ wget https://bootstrap.pypa.io/get-pip.py
$ python3.8 get-pip.py
# Upgrade pip
$ python3.8 -m pip install --upgrade pip
# Install virtualenv
$ python3.8 -m pip install virtualenv
# Create GoDataID_anomalib environment
$ python3.8 -m virtualenv -p python3.8 GoDataID_anomalib
# activate GoDataID_anomalib environment
$ . ./GoDataID_anomalib/bin/activate
# install psutil
$ python -m pip install psutil --find-links=https://ddelange.github.io/psutil/
# install anomalib
$ cd anomalib
$ python -m pip install -e .