dusty-nv / jetson-containers

Machine Learning Containers for NVIDIA Jetson and JetPack-L4T
MIT License
1.89k stars 416 forks source link

Unable to build opencv with python 3.12 on Jetson Orin Nano due to subprocess exited with error: AttributeError: module 'pkgutil' has no attribute 'ImpImporter' #497

Open collinli2353 opened 2 months ago

collinli2353 commented 2 months ago

Setup:

What works

Error

error.txt

Shortened version below:

  Installing build dependencies: finished with status 'error'
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
The command '/bin/sh -c /tmp/opencv/opencv_install_deps.sh &&     pip3 install --no-cache-dir    opencv-contrib-python~=${OPENCV_VERSION}     || /tmp/opencv/build.sh' returned a non-zero code: 1
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/cuauv-jon/Documents/jetson-containers/jetson_containers/build.py", line 103, in <module>
    build_container(args.name, args.packages, args.base, args.build_flags, args.simulate, args.skip_tests, args.test_only, args.push, args.no_github_api)
  File "/home/cuauv-jon/Documents/jetson-containers/jetson_containers/container.py", line 143, in build_container
    status = subprocess.run(cmd.replace(_NEWLINE_, ' '), executable='/bin/bash', shell=True, check=True)
  File "/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'DOCKER_BUILDKIT=0 docker build --network=host --tag py312:r35.4.1-cp312-opencv --file /home/cuauv-jon/Documents/jetson-containers/packages/opencv/Dockerfile.pip --build-arg BASE_IMAGE=py312:r35.4.1-cp312-numpy --build-arg OPENCV_VERSION="4.8.1" --build-arg OPENCV_PYTHON="4.x" --build-arg CUDA_ARCH_BIN="7.2,8.7" /home/cuauv-jon/Documents/jetson-containers/packages/opencv 2>&1 | tee /home/cuauv-jon/Documents/jetson-containers/logs/20240429_172346/build/py312_r35.4.1-cp312-opencv.txt; exit ${PIPESTATUS[0]}' returned non-zero exit status 1.
Kerkuil-Geoglossum commented 2 months ago

The issue is a result of the an incorrect version of pip being used in the build process. see this link for more on that. I don't know how to fix it as far as Dustynv's building scripts. I am suffering the same error. https://stackoverflow.com/questions/77364550/attributeerror-module-pkgutil-has-no-attribute-impimporter-did-you-mean

ms1design commented 1 month ago

@collinli2353, if what @Kerkuil-Geoglossum wrote is true, you should read how to set up the correct Python version before building the image. This should resolve your issues.