# Python binding not found for TensorRT

**URL:** <https://forums.developer.nvidia.com/t/python-binding-not-found-for-tensorrt/76408>\
**Category:** TensorRT\
**Created:** [June 14, 2019, 4:27am UTC](https://forums.developer.nvidia.com/t/python-binding-not-found-for-tensorrt/76408 "2019-06-14T04:27:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jageshmaharjan](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jageshmaharjan](https://forums.developer.nvidia.com/u/jageshmaharjan)\
**Post date:** [June 14, 2019, 4:27am UTC](https://forums.developer.nvidia.com/t/python-binding-not-found-for-tensorrt/76408/1 "2019-06-14T04:27:02Z")

</div>

Linux distro and version : ubuntu 18.04  
GPU type : NVIDIA GTX 1060  
nvidia driver version : 415.27  
CUDA version : 10.1  
CUDNN version : 9.1  
Python version [if using python] : 3.6.2  
Tensorflow version : 1.13  
TensorRT version : 5.0  
If Jetson, OS, hw versions : n/a

I’ve followed the instruction as to install tensorRT, everything went good, however, I couldn’t import tensorrt module in python.

After, installation i checked if python binding shows up or no.

```auto
(myenv) jugs@jugs:~$ dpkg -l | grep TensorRT
ii graphsurgeon-tf 5.0.2-1+cuda10.0 amd64 GraphSurgeon for TensorRT package
ii libnvinfer-dev 5.0.2-1+cuda10.0 amd64 TensorRT development libraries and headers
ii libnvinfer-samples 5.0.2-1+cuda10.0 all TensorRT samples and documentation
ii libnvinfer5 5.0.2-1+cuda10.0 amd64 TensorRT runtime libraries
ii python-libnvinfer 5.0.2-1+cuda10.0 amd64 Python bindings for TensorRT
ii python-libnvinfer-dev 5.0.2-1+cuda10.0 amd64 Python development package for TensorRT
ii python3-libnvinfer 5.0.2-1+cuda10.0 amd64 Python 3 bindings for TensorRT
ii python3-libnvinfer-dev 5.0.2-1+cuda10.0 amd64 Python 3 development package for TensorRT
ii tensorrt 5.0.2.6-1+cuda10.0 amd64 Meta package of TensorRT
ii uff-converter-tf 5.0.2-1+cuda10.0 amd64 UFF converter for TensorRT package
(myenv) jugs@jugs:~$

```

Regardless, everything is available, but I still couldn’t import the python module.  
I have a tensorflow version 1.13, and python 3.x in anaconda environment,

```auto
Python 3.6.2 |Anaconda, Inc.| (default, Oct 5 2017, 07:59:26) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> print(tf. __version__ )
1.13.1
>>> import tensorrt as trt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorrt'
>>>

```

And, my NVIDIA driver and cuda driver version is as shown below,

```auto
(myenv) jugs@jugs:~$ nvidia-smi
Fri Jun 14 12:24:44 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 415.27 Driver Version: 415.27 CUDA Version: 10.0 |
|-------------------------------+----------------------+----------------------+

```

---

<div class="post-metadata">

**Author:** ![afiqlcmec](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@afiqlcmec](https://forums.developer.nvidia.com/u/afiqlcmec)\
**Post date:** [July 11, 2019, 9:46am UTC](https://forums.developer.nvidia.com/t/python-binding-not-found-for-tensorrt/76408/2 "2019-07-11T09:46:48Z")

</div>

same issue. do you have this resolved?

---

<div class="post-metadata">

**Author:** ![NVES\_R](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nves_r/32/14043_2.png) [@NVES\_R](https://forums.developer.nvidia.com/u/NVES_R)\
**Post date:** [July 11, 2019, 9:00pm UTC](https://forums.developer.nvidia.com/t/python-binding-not-found-for-tensorrt/76408/3 "2019-07-11T21:00:13Z")

</div>

Hi,

This issue is usually related to the difference between a system Python3 install and an Anaconda Python3 install. The debian TensorRT package installation seems to use the system Python3 version.

First, I believe the TensorRT Python3 package is usually for Python3.5 by default and your Anaconda version is Python3.6.2. So you could try to downgrade your Anaconda version to 3.5 to see if it can pick up TensorRT as mentioned in this post: [url][https://devtalk.nvidia.com/default/topic/1030265/tensorrt/python-quot-import-tesnorrt-quot-error-modulenotfounderror-no-module-named-tensorrt-/post/5261495/#5261495[/url]](https://devtalk.nvidia.com/default/topic/1030265/tensorrt/python-quot-import-tesnorrt-quot-error-modulenotfounderror-no-module-named-tensorrt-/post/5261495/#5261495%5B/url%5D)

Or you could try uninstalling Anaconda and just using the system Python3 version instead as mentioned here: [url][https://devtalk.nvidia.com/default/topic/1030265/tensorrt/python-quot-import-tesnorrt-quot-error-modulenotfounderror-no-module-named-tensorrt-/post/5241538/#5241538[/url]](https://devtalk.nvidia.com/default/topic/1030265/tensorrt/python-quot-import-tesnorrt-quot-error-modulenotfounderror-no-module-named-tensorrt-/post/5241538/#5241538%5B/url%5D)

Thanks,  
NVIDIA Enterprise Support

---

<div class="post-metadata">

**Author:** ![Borislav](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Borislav](https://forums.developer.nvidia.com/u/Borislav)\
**Post date:** [October 2, 2019, 10:54pm UTC](https://forums.developer.nvidia.com/t/python-binding-not-found-for-tensorrt/76408/4 "2019-10-02T22:54:22Z")

</div>

Is Python3.5 a hard requirement for installing the python binding of TensorRT-6.0.1.5? The TensorRT install guide does not indicate at any point that a particular Python version is required.

I have Ubuntu 18.04 with Python3.6.8 only (not any Python3.5.x is installed on my machine). I tried to install TensorRT-6.0.1.5 from  
(1) Debian package  
(2) tar file

in a virtual environment (created with venv).

I was able to complete each of the installation procedures without any error messages. In both cases TesnsorRT can not be imported in Python inside my virtual environment:

> > > import tensorrt as trt  
> > > Traceback (most recent call last):  
> > > File “”, line 1, in   
> > > ModuleNotFoundError: No module named ‘tensorrt’

However, if I deactivate the virtual environment and start the system Python3, I can import TensorRT, i.e.

> > import tensorrt as trt

goes through without error message. (Of course, all other packages they I need are installed in the virtual environment only and so I do not have a working combination.)

Do I miss anything special I need to do to install TensorRT in a virtual environment? Or the Python version (3.5 vs 3.6) might be a problem?

---

<div class="post-metadata">

**Author:** ![oren.bell](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@oren.bell](https://forums.developer.nvidia.com/u/oren.bell)\
**Post date:** [September 25, 2020, 5:55pm UTC](https://forums.developer.nvidia.com/t/python-binding-not-found-for-tensorrt/76408/5 "2020-09-25T17:55:46Z")

</div>

Bump this. I can also confirm my python3-libnvinfer package is installed correctly, but not visible inside a virtual environment.

The only fix I’ve found is [here](https://docs.donkeycar.com/guide/robot_sbc/tensorrt_jetson_nano/), where they say I have to add my dist-packages to my virtual environment. Which kinda defeats the point of a virtual environment

---

<div class="post-metadata">

**Author:** ![eval-nv](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@eval-nv](https://forums.developer.nvidia.com/u/eval-nv)\
**Post date:** [October 5, 2020, 8:50pm UTC](https://forums.developer.nvidia.com/t/python-binding-not-found-for-tensorrt/76408/6 "2020-10-05T20:50:56Z")

</div>

Thanks for the info. Nvidia better to make it pip-installable

---

<div class="post-metadata">

**Author:** ![TomNVIDIA](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/tomnvidia/32/14181_2.png) [@TomNVIDIA](https://forums.developer.nvidia.com/u/TomNVIDIA)\
**Post date:** [October 12, 2021, 7:47pm UTC](https://forums.developer.nvidia.com/t/python-binding-not-found-for-tensorrt/76408/7 "2021-10-12T19:47:35Z")

</div>

Closed on October 12, 2021, 7:47pm UTC


