I need to use jetson_inference and jetson_utils in a python 3.7 environment on my Jetson Nano. I created a virtual environment that has python3.7 as the default python3 and I rebuilt various packages from source (OpenCV, NumPy, etc). and installed them. They seem to work fine and I can import them from a python3.7 (also works when I call python3, which points to python3.7 in my virtual environment).
When I build jetson_inference I see the following in the output, which is as expected"
-- trying to build Python bindings for Python versions: 2.7;3.7
-- detecting Python 2.7...
-- found Python version: 2.7 (2.7.17)
-- found Python include: /usr/include/python2.7
-- found Python library: /usr/lib/aarch64-linux-gnu/libpython2.7.so
-- CMake module path: /home/marc/venvirons/p37test/jetson-inference/utils/cuda;/home/marc/venvirons/p37test/jetson-inference/python/bindings;/home/marc/venvirons/p37test/jetson-inference/python/bindings/../../utils/python/bindings
-- NumPy ver. 1.13.3 found (include: /usr/lib/python2.7/dist-packages/numpy/core/include)
-- found NumPy version: 1.13.3
-- found NumPy include: /usr/lib/python2.7/dist-packages/numpy/core/include
-- detecting Python 3.7...
-- found Python version: 3.7 (3.7.5)
-- found Python include: /usr/include/python3.7m
-- found Python library: /usr/lib/aarch64-linux-gnu/libpython3.7m.so
-- CMake module path: /home/marc/venvirons/p37test/jetson-inference/utils/cuda;/home/marc/venvirons/p37test/jetson-inference/python/bindings;/home/marc/venvirons/p37test/jetson-inference/python/bindings/../../utils/python/bindings
-- NumPy ver. 1.20.3 found (include: /home/marc/venvirons/p37test/venv/lib/python3.7/site-packages/numpy/core/include)
-- found NumPy version: 1.20.3
-- found NumPy include: /home/marc/venvirons/p37test/venv/lib/python3.7/site-packages/numpy/core/include
As you can see, it finds NumPy 1.20.3 in the virtual env’s site-packages folder and all is well. However, when I do sudo make install I see the following errors in the output:
-- trying to build Python bindings for Python versions: 2.7;3.7
-- detecting Python 2.7...
-- found Python version: 2.7 (2.7.17)
-- found Python include: /usr/include/python2.7
-- found Python library: /usr/lib/aarch64-linux-gnu/libpython2.7.so
-- CMake module path: /home/marc/venvirons/p37test/jetson-inference/utils/cuda;/home/marc/venvirons/p37test/jetson-inference/utils/python/bindings
-- NumPy ver. 1.13.3 found (include: /usr/lib/python2.7/dist-packages/numpy/core/include)
-- found NumPy version: 1.13.3
-- found NumPy include: /usr/lib/python2.7/dist-packages/numpy/core/include
-- detecting Python 3.7...
-- found Python version: 3.7 (3.7.5)
-- found Python include: /usr/include/python3.7m
-- found Python library: /usr/lib/aarch64-linux-gnu/libpython3.7m.so
-- CMake module path: /home/marc/venvirons/p37test/jetson-inference/utils/cuda;/home/marc/venvirons/p37test/jetson-inference/utils/python/bindings
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 16, in <module>
from . import multiarray
ImportError: cannot import name 'multiarray' from 'numpy.core' (/usr/lib/python3/dist-packages/numpy/core/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3/dist-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/usr/lib/python3/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/python3/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/lib/python3/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: cannot import name 'multiarray' from 'numpy.core' (/usr/lib/python3/dist-packages/numpy/core/__init__.py)
-- NumPy not found
It appears to be using the /usr/lib/python3 folder for installed packages instead of /home/marc/venvirons/p37test/venv/lib/python3.7/site-packages.
Does anyone know how to get around this? Is there an argument I can pass to make install to force it to use the desired path? Is it a CMake arg I need to use?
Thanks in advance!