How to resolve the missing configuration file error below on the Jetson Nano

How do I resolve the missing configuration file error below:
(I’m using Jetpack 4.6.1, the default version of Python is 3.6.9 and I have installed Python 3.8.0 on the Jetson Nano.)

The command opencv_version returns 4.8.0 and python3 returns 3.8.0.
But python3 -c "import cv2; print('OpenCV version:', str(cv2.__version__)); results in the error below:

 nikhil@nikhil:~$ opencv_version
4.8.0
nikhil@nikhil:~$ python3 -c "import cv2; print('OpenCV version:', str(cv2.__version__)); print(cv2.getBuildInformation())"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/usr/local/lib/python3.6/site-packages/cv2/__init__.py", line 112, in bootstrap
    load_first_config([
  File "/usr/local/lib/python3.6/site-packages/cv2/__init__.py", line 109, in load_first_config
    raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames))
ImportError: OpenCV loader: missing configuration file: ['config-3.8.py', 'config-3.py']. Check OpenCV installation.

ERR (1)~2

Please help me resolve this.

Hi,

When you import the package with Python3.8, it looks for the package that under the Python3.6 and leads to the error.
Could you try the below command to see if it works?

echo 'export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
echo 'export PYTHONPATH=/usr/local/lib/python3.8/site-packages/:$PYTHONPATH' >> ~/.bashrc
source ~/.bashrc

Thanks.

nikhil@nikhil:~$ echo 'export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
nikhil@nikhil:~$ echo 'export PYTHONPATH=/usr/local/lib/python3.8/site-packages/:$PYTHONPATH' >> ~/.bashrc
nikhil@nikhil:~$ source ~/.bashrc
nikhil@nikhil:~$ nano .bashrc
nikhil@nikhil:~$ nano .bashrc
nikhil@nikhil:~$ opencv_version
4.8.0
nikhil@nikhil:~$ python3 --version
Python 3.8.0
nikhil@nikhil:~$ python3
Python 3.8.0 (default, Dec  9 2021, 17:53:27) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/usr/local/lib/python3.6/site-packages/cv2/__init__.py", line 112, in bootstrap
    load_first_config([
  File "/usr/local/lib/python3.6/site-packages/cv2/__init__.py", line 109, in load_first_config
    raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames))
ImportError: OpenCV loader: missing configuration file: ['config-3.8.py', 'config-3.py']. Check OpenCV installation.
>>> 

The error has not resolved, pls help. @AastaLLL

Appended the two lines below in the bashrc file:

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export PYTHONPATH=/usr/local/lib/python3.8/site-packages/:$PYTHONPATH

Hi,

Have you built OpenCV with Python3.8?

You can follow the below instructions but update to your python version:

Thanks.

Yes.

I’m required to install Python 3.8 or later versions, (the step shared above seems to be for Python 3.6) just so that I’m able to install the Ultralytics package.

Please share the steps to install Python 3.8 and OpenCV with Cuda support for the Jetson Nano.

Here are the steps I followed to install python 3.8:

sudo apt update
sudo apt upgrade
sudo apt install build-essential libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev 
libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev libffi-dev libc6-dev
wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tar.xz
tar -xf Python-3.8.12.tar.xz
cd Python-3.8.12
./configure --enable-optimizations
make -j4
sudo make altinstall
python3.8 --version

Added the python site-packages path in the .bashrc file.

After installation of Python 3.8, created a virtual env and went on to install Ultralytics: pip3 install ultralytics
Ever since I tried installing Ultralytics, I’ve been getting the error above. How go I resolve this, kindly help.

@AastaLLL Kindly revert

Hi,

You will need to build OpenCV with Python 3.8 as well.
The default version is built with Python 3.6.

Have you built it from the source with Python 3.8?
Thanks.

Yes, I’ve built OpenCV from source for Python 3.8

How do I check if OpenCV is built with CUDA support? @AastaLLL

How do i enable cuda support for OpenCV? @AastaLLL

Hi,

You can find it in the building info:

print(cv2.getBuildInformation())

Thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.