Strawberryfields: TypeError: Unable to convert function return value

I get the following error when I import strawberryfields:

# !pip install -q strawberryfields --upgrade*

import strawberryfields as sf*
from strawberryfields.ops import **
2024-02-01 11:35:10.623996: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2024-02-01 11:35:10.676895: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2024-02-01 11:35:10.677626: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
ImportError: numpy.core._multiarray_umath failed to import
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
ImportError: numpy.core.umath failed to import
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
ImportError: numpy.core._multiarray_umath failed to import
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
ImportError: numpy.core.umath failed to import
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
ImportError: numpy.core._multiarray_umath failed to import
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
ImportError: numpy.core.umath failed to import
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_4797/2550986783.py in <module>
      1 # !pip install -q strawberryfields --upgrade
      2 
----> 3 import strawberryfields as sf
      4 from strawberryfields.ops import *

/opt/conda/lib/python3.9/site-packages/strawberryfields/__init__.py in <module>
     22     :target: javascript:void(0);
     23 """
---> 24 from . import apps
     25 from ._version import __version__
     26 from .engine import Engine, LocalEngine, RemoteEngine

/opt/conda/lib/python3.9/site-packages/strawberryfields/apps/__init__.py in <module>
     34 import strawberryfields.apps.plot
     35 import strawberryfields.apps.points
---> 36 import strawberryfields.apps.qchem
     37 import strawberryfields.apps.sample
     38 import strawberryfields.apps.similarity

/opt/conda/lib/python3.9/site-packages/strawberryfields/apps/qchem/__init__.py in <module>
     32     read_gamess
     33 """
---> 34 import strawberryfields.apps.qchem.dynamics
     35 import strawberryfields.apps.qchem.vibronic
     36 from strawberryfields.apps.qchem.utils import duschinsky, read_gamess

/opt/conda/lib/python3.9/site-packages/strawberryfields/apps/qchem/dynamics.py in <module>
     71 
     72 import strawberryfields as sf
---> 73 from strawberryfields.utils import operation
     74 
     75 

/opt/conda/lib/python3.9/site-packages/strawberryfields/utils/__init__.py in <module>
     19 from .gbs_analysis import *
     20 from .post_processing import *
---> 21 from .program_functions import *
     22 from .random_numbers_matrices import *
     23 from .states import *

/opt/conda/lib/python3.9/site-packages/strawberryfields/utils/program_functions.py in <module>
     20 
     21 try:
---> 22     import tensorflow as tf
     23 except ImportError:
     24     tf_available = False

/opt/conda/lib/python3.9/site-packages/tensorflow/__init__.py in <module>
     36 import typing as _typing
     37 
---> 38 from tensorflow.python.tools import module_util as _module_util
     39 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
     40 

/opt/conda/lib/python3.9/site-packages/tensorflow/python/__init__.py in <module>
     35 
     36 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
---> 37 from tensorflow.python.eager import context
     38 
     39 # pylint: enable=wildcard-import

/opt/conda/lib/python3.9/site-packages/tensorflow/python/eager/context.py in <module>
     34 from tensorflow.python.client import pywrap_tf_session
     35 from tensorflow.python.eager import cancellation
---> 36 from tensorflow.python.eager import execute
     37 from tensorflow.python.eager import executor
     38 from tensorflow.python.eager import monitoring

/opt/conda/lib/python3.9/site-packages/tensorflow/python/eager/execute.py in <module>
     19 from tensorflow.python import pywrap_tfe
     20 from tensorflow.python.eager import core
---> 21 from tensorflow.python.framework import dtypes
     22 from tensorflow.python.framework import tensor_conversion_registry
     23 from tensorflow.python.framework import tensor_shape

/opt/conda/lib/python3.9/site-packages/tensorflow/python/framework/dtypes.py in <module>
     36 from tensorflow.python.framework import cpp_shape_inference_pb2
     37 
---> 38 _np_bfloat16 = pywrap_bfloat16.bfloat16_type()
     39 _np_float8_e4m3fn = _pywrap_float8.TF_float8_e4m3fn_type()
     40 _np_float8_e5m2 = _pywrap_float8.TF_float8_e5m2_type()

TypeError: Unable to convert function return value to a Python type! The signature was
	() -> handle

Hey @RX1,

Can you provide a bit more detail? E.g., what are you running your code in, what your operating system is, etc.