Trouble Importing Tensorflow with Python on Jetson Nano

Hello, I am having some issues with the installation of Tensorflow on my Jetson Nano 4GB. I am running Jetpack 4.6.1 and followed a few forum posts on here to install Tensorflow 2.7.0+nv22.1, however when I try to import it into python I get the following error:

Python 3.6.9 (default, Mar 10 2023, 16:46:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python.feature_column import feature_column_lib as feature_column
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/feature_column/feature_column_lib.py", line 22, in <module>
    from tensorflow.python.feature_column.feature_column import *
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/feature_column/feature_column.py", line 147, in <module>
    from tensorflow.python.layers import base
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/layers/base.py", line 20, in <module>
    from tensorflow.python.keras.legacy_tf_layers import base
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/__init__.py", line 25, in <module>
    from tensorflow.python.keras import models
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/models.py", line 20, in <module>
    from tensorflow.python.keras import metrics as metrics_module
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/metrics.py", line 34, in <module>
    from tensorflow.python.keras import activations
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/activations.py", line 18, in <module>
    from tensorflow.python.keras.layers import advanced_activations
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/layers/__init__.py", line 29, in <module>
    from tensorflow.python.keras.layers.preprocessing.image_preprocessing import CenterCrop
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/layers/preprocessing/image_preprocessing.py", line 28, in <module>
    from tensorflow.python.keras.preprocessing import image as image_preprocessing
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/preprocessing/__init__.py", line 26, in <module>
    from tensorflow.python.keras.utils import all_utils as utils
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/utils/all_utils.py", line 34, in <module>
    from tensorflow.python.keras.utils.multi_gpu_utils import multi_gpu_model
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/utils/multi_gpu_utils.py", line 19, in <module>
    from tensorflow.python.keras.engine.training import Model
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py", line 52, in <module>
    from tensorflow.python.keras.saving import hdf5_format
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/saving/hdf5_format.py", line 37, in <module>
    import h5py
  File "/usr/local/lib/python3.6/dist-packages/h5py/__init__.py", line 45, in <module>
    from ._conv import register_converters as _register_converters, \
  File "h5py/h5t.pxd", line 15, in init h5py._conv
  File "h5py/h5t.pyx", line 261, in init h5py.h5t
  File "h5py/h5t.pyx", line 256, in h5py.h5t._get_available_ftypes
AttributeError: 'numpy.dtype' object has no attribute 'typeobj'


for reference, here are some of the relevant packages I have installed, hopefully this is enough info to solve the issue:

$ pip3 list
Package                       Version
----------------------------- -------------------

Cython                        0.26.1
h5py                          3.1.0
keras                         2.10.0
Keras-Applications            1.0.8
Keras-Preprocessing           1.1.2
matplotlib                    2.1.1
numpy                         1.19.4
pandas                        0.22.0
Pillow                        8.4.0
pip                           21.3.1
protobuf                      3.19.6
setuptools                    59.6.0
tensorflow                    2.7.0+nv22.1
tensorflow-estimator          2.8.0

Hi,

Could you upgrade Cython to v0.29.x?

$ pip3 install 'Cython<3'

Based on the below issue, the compatibility problem is fixed in cython>=0.29

Thanks.

I tried but it just tells me "Requirement already satisfied: Cython<3 in /usr/lib/python3/dist-packages (0.26.1)
I then tried to first remove the existing version using

$ pip3 uninstall Cython

but it gave

ERROR: Cannont uinstall 'Cython', It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

Hi,

Could you try to install 0.29?
It looks like your cython is still 0.26.

Thanks.

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