# Can't Import TFBertModel

**URL:** <https://discuss.huggingface.co/t/cant-import-tfbertmodel/95248>\
**Category:** 🤗Transformers\
**Created:** [July 3, 2024, 4:14am UTC](https://discuss.huggingface.co/t/cant-import-tfbertmodel/95248 "2024-07-03T04:14:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshyii](https://avatars.discourse-cdn.com/v4/letter/j/7993a0/32.png) [@joshyii](https://discuss.huggingface.co/u/joshyii)\
**Post date:** [July 3, 2024, 4:14am UTC](https://discuss.huggingface.co/t/cant-import-tfbertmodel/95248/1 "2024-07-03T04:14:39Z")

</div>

Code: from transformers import TFBertModel

Error:  
AttributeError Traceback (most recent call last) File c:\Users\rtrct\AppData\Local\Programs\Python\Python312\Lib\site-packages\transformers\utils\import\_utils.py:1560, in \_LazyModule._get\_module(self, module\_name) [1559](file:///C:/Users/rtrct/AppData/Local/Programs/Python/Python312/Lib/site-packages/transformers/utils/import\_utils.py:1559) try: → [1560](file:///C:/Users/rtrct/AppData/Local/Programs/Python/Python312/Lib/site-packages/transformers/utils/import\_utils.py:1560) return importlib.import\_module(“.” + module\_name, self. **name** ) [1561](file:///C:/Users/rtrct/AppData/Local/Programs/Python/Python312/Lib/site-packages/transformers/utils/import\_utils.py:1561) except Exception as e: File c:\Users\rtrct\AppData\Local\Programs\Python\Python312\Lib\importlib\_init_.py:90, in import\_module(name, package) [89](file:///C:/Users/rtrct/AppData/Local/Programs/Python/Python312/Lib/importlib/ **init**.py:89) level += 1 —\> [90](file:///C:/Users/rtrct/AppData/Local/Programs/Python/Python312/Lib/importlib/ **init**.py:90) return \_bootstrap.\_gcd\_import(name[level:], package, level) File :1387, in \_gcd\_import(name, package, level) File :1360, in _find\_and\_load(name, import_) File :1331, in _find\_and\_load\_unlocked(name, import_) File :935, in \_load\_unlocked(spec) File :995, in exec\_module(self, module) File :488, in \_call\_with\_frames\_removed(f, \*args, \*\*kwds) File c:\Users\rtrct\AppData\Local\Programs\Python\Python312\Lib\site-packages\transformers\models\bert\modeling\_tf\_bert.py:28 [26](file:///C:/Users/rtrct/AppData/Local/Programs/Python/Python312/Lib/site-packages/transformers/models/bert/modeling\_tf\_bert.py:26) import tensorflow as tf

…

[1564](file:///C:/Users/rtrct/AppData/Local/Programs/Python/Python312/Lib/site-packages/transformers/utils/import\_utils.py:1564) f" traceback):\n{e}" [1565](file:///C:/Users/rtrct/AppData/Local/Programs/Python/Python312/Lib/site-packages/transformers/utils/import\_utils.py:1565) ) from e RuntimeError: Failed to import transformers.models.bert.modeling\_tf\_bert because of the following error (look up to see its traceback): module ‘tensorflow.\_api.v2.compat.v2. **internal** ’ has no attribute ‘register\_load\_context\_function’

HI, I have tried many times by changing the Tensorflow and Transformers version but it does not solve the issue. Please help!
