Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 this issue Apr 30, 2024 · 2 comments

Comments

@collinli2353
Copy link

Setup:

  • Set environmental variable export PYTHON_VERSION=3.12
  • Run ./build.sh --name=my_container build-essential cmake cuda cudnn gstreamer numpy onnx opencv protobuf:cpp pycuda python pytorch tensorrt tensorflow2 torch2trt torchvision

What works

  • Just running ./build.sh --name=my_container build-essential cmake cuda cudnn gstreamer numpy onnx opencv protobuf:cpp pycuda python pytorch tensorrt tensorflow2 torch2trt torchvision works but it installs for python 3.8

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
Copy link

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
Copy link
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants