Error after installing TensorFlow in Ubuntu 22.04

Following error arises after installing TensorFlow in Ubuntu 22.04, request anyone to throw some light to fix this issue(error details added below). Thanks in advance.

$ python3 -c “import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))”
2023-07-21 16:58:48.171036: I tensorflow/tsl/cuda/] Could not find cuda drivers on your machine, GPU will not be used.
2023-07-21 16:58:48.230884: I tensorflow/tsl/cuda/] Could not find cuda drivers on your machine, GPU will not be used.
2023-07-21 16:58:48.231404: I tensorflow/core/platform/] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Traceback (most recent call last):
File “”, line 1, in
File “/home/surya/miniconda3/envs/myenv/lib/python3.11/site-packages/tensorflow/”, line 38, in
from import module_util as _module_util
File “/home/surya/miniconda3/envs/myenv/lib/python3.11/site-packages/tensorflow/python/”, line 37, in
from tensorflow.python.eager import context
File “/home/surya/miniconda3/envs/myenv/lib/python3.11/site-packages/tensorflow/python/eager/”, line 36, in
from tensorflow.python.eager import execute
File “/home/surya/miniconda3/envs/myenv/lib/python3.11/site-packages/tensorflow/python/eager/”, line 23, in
from tensorflow.python.framework import tensor_shape
File “/home/surya/miniconda3/envs/myenv/lib/python3.11/site-packages/tensorflow/python/framework/”, line 26, in
from tensorflow.python.saved_model import nested_structure_coder
File “/home/surya/miniconda3/envs/myenv/lib/python3.11/site-packages/tensorflow/python/saved_model/”, line 38, in
from tensorflow.python.util import nest
File “/home/surya/miniconda3/envs/myenv/lib/python3.11/site-packages/tensorflow/python/util/”, line 86, in
import wrapt as _wrapt
File “/home/surya/miniconda3/envs/myenv/lib/python3.11/site-packages/wrapt/”, line 10, in
from .decorators import (adapter_factory, AdapterFactory, decorator,
File “/home/surya/miniconda3/envs/myenv/lib/python3.11/site-packages/wrapt/”, line 34, in
from inspect import ismethod, isclass, formatargspec
ImportError: cannot import name ‘formatargspec’ from ‘inspect’ (/home/surya/miniconda3/envs/myenv/lib/python3.11/

Hey, I recently did my install on WSL and there are multiple things that can go wrong. I don’t know about this particular error, but it’s good to always check the official guide

Main points I could see going wrong here are:

  1. From the logs you do not have CUDA drivers on your machine, are you sure you want to do a GPU install?
  2. If you do, did you install cuda toolkit and cudnn first? (with sudo update and upgrade to make sure)
  3. Are you sure you need to use python at 3.11 for this? It does seem like that particular module has a problem with this python version. Also, what tf version are you using? TensorFlow supports python 3.11 officially, but not all tf versions do so.

I would first retry the install in a different environment with a downgraded python version and decide if it should be CUDA enabled or not.