Tensorrt is installed but not getting detected

I have tensorrt installed in my system but it is not getting detected when i try to import it

agxorin@ubuntu:~$ python
Python 2.7.18 (default, Jul  1 2022, 12:27:04) 
[GCC 9.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorrt as trt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named tensorrt
>>> exit()
agxorin@ubuntu:~$ sudo apt install tensorrt
[sudo] password for agxorin: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
tensorrt is already the newest version (

kindly help me to set it its right PATH in shelll


We now only support Python3 by default.
Please try it with python3.

$ python3
Python 3.8.10 (default, Nov 22 2023, 10:22:35)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorrt as trt
>>> trt.__version__


Thanks for the reply. I am able to run the system. I am unable to import it in virtual environment


How do you create the virtual environment?
For virtualenv, please try to export the below flag:

$ virtualenv env --system-site-packages


Thank you for the info. This solved my issue.

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