ImportError: cannot import name 'get_keras_submodule' from partially initialized module 'keras_applications' (most likely due to a circular import) - tensorflow

I use python 3.8.6 and I have loaded Keras 2.2.2, TensorFlow-GPU 2.2.0.
When I run my code, I have this error:
Using TensorFlow backend.
Traceback (most recent call last):
File "XX.py", line 23, in <module>
import keras
File ".local/lib/python3.8/site-packages/keras/__init__.py", line 5, in <module>
from . import applications
File ".local/lib/python3.8/site-packages/keras/applications/__init__.py", line 11, in <module>
import keras_applications
File ".local/lib/python3.8/site-packages/keras_applications/__init__.py", line 8, in <module>
from keras_applications import vgg16
File ".local/lib/python3.8/site-packages/keras_applications/vgg16.py", line 15, in <module>
from . import get_keras_submodule
ImportError: cannot import name 'get_keras_submodule' from partially initialized module 'keras_applications' (most likely due to a circular import) (/local/lib/python3.8/site-packages/keras_applications/__init__.py)
How to solve this error other than downgrade the TensorFlow version?
Thanks!

Related

odoo app wont launch due to circular import (cannot import name 'SUPERUSER_ID')

I've been trying to get odoo 15 to work for a bit while and after installing all dependencies and trying to run the app I've come into this error.
Traceback (most recent call last):
File "C:\odoo-15-test\server\odoo-bin", line 4, in <module>
import odoo
File "C:\odoo-15-test\server\odoo\__init__.py", line 11, in <module>
from . import http
File "C:\odoo-15-test\server\odoo\http.py", line 50, in <module>
from .service.server import memory_info
File "C:\odoo-15-test\server\odoo\service\__init__.py", line 4, in <module>
from . import common
File "C:\odoo-15-test\server\odoo\service\common.py", line 6, in <module>
import odoo.tools
File "C:\odoo-15-test\server\odoo\tools\__init__.py", line 21, in <module>
from .convert import *
File "C:\odoo-15-test\server\odoo\tools\convert.py", line 33, in <module>
from odoo import SUPERUSER_ID, api
File "C:\odoo-15-test\server\odoo\api.py", line 1022, in <module>
from odoo import SUPERUSER_ID
ImportError: cannot import name 'SUPERUSER_ID' from partially initialized module 'odoo' (most likely due to a circular import) (C:\odoo-15-test\server\odoo\__init__.py)
I have tried installing odoo with 'pip install odoo' but this didnt work and I don't see this being the problem. I have also never run into circular imports before so any help would be great thanks.

Keras.module needs Tf version=>2.2, but DLL's Tf load failed

This is my first question here, 'cos I am normally able to find someone else asking the same question in stackoverflow and the answers are usually very clear and detailed.
Unfortutately this time I find myself in a corner.
I am using anaconda3 (64bit) from a Win10 and I would like to import
from keras.models import Model
Unfortunately I get the following issue:
File "...\Anaconda3\lib\site-packages\keras\__init__.py", line 6, in <module>
'Keras requires TensorFlow 2.2 or higher. '
ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow`
When I have updated tensorflow to the newest version possible "2.3", I believe, but unfortunately this conflict with this other problem:
In [1]: import tensorflow as tf
Traceback (most recent call last):
File "<ipython-input-1-64156d691fe5>", line 1, in <module>
import tensorflow as tf
File "...\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "...\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "...\Anaconda3\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "...\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "...\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "...\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Do you have any suggestion?
use tf.keras.Model
Keras is implemented by default in Tensorflow 2.0

No module named 'tensorflow_datasets.image.cityscapes'

I installed TensorFlow Datasets using conda, as:
conda install -c anaconda tensorflow-datasets
I've tried importing Cityscapes:
from tensorflow_datasets.image.cityscapes import Cityscapes
but this raises the following error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'tensorflow_datasets.image.cityscapes'
How can I fix it?
PS: I can import the following without errors:
import tensorflow_datasets as tfds
Edit:
I've already downloaded Cityscapes data, as recommended in the official guide.

Tensorflow object detection: neither model_main.py nor train.py work anymore

train.py
Traceback (most recent call last):
File "object_detection/legacy/train.py", line 48, in <module>
from tensorflow.contrib import framework as contrib_framework
ModuleNotFoundError: No module named 'tensorflow.contrib'
module_main.py
Traceback (most recent call last):
File "object_detection/model_main.py", line 26, in <module>
from object_detection import model_lib
File "/content/models/research/object_detection/model_lib.py", line 27, in <module>
from object_detection import eval_util
File "/content/models/research/object_detection/eval_util.py", line 40, in <module>
slim = tf.contrib.slim
AttributeError: module 'tensorflow' has no attribute 'contrib'
I can't even export my model from checkpoint to inference graph because of the same error.
export_inference_graph.py
Traceback (most recent call last):
File "object_detection/export_inference_graph.py", line 108, in <module>
from object_detection import exporter
File "/content/models/research/object_detection/exporter.py", line 20, in <module>
from tensorflow.contrib.quantize.python import graph_matcher
ModuleNotFoundError: No module named 'tensorflow.contrib'
All three files worked perfectly up until today. Training worked with TF 1.15 and 2.1.0. I was using Colab with Python 3.6 and GPU training. I also could not find any substantial changes recently in the github repo of tensorflow.
Any ideas guys?

numpy pandas not working in IDLE / work in Anaconda

I am running Python 3.5.1 on Windows 10 and have Anaconda and IDLE installed.
If I run any Python files, pandas and numpy seem to work in Jupyter notebooks, but not in IDLE.
I have ensured that the PATH and PYTHONPATH environment variables include access to the folders where pandas and numpy are located (Lib/site-packages).
I receive the following error in IDLE when trying to import pandas:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import pandas
File "C:\Users\me\AppData\Local\Continuum\Anaconda3\Lib\site-packages\pandas\__init__.py", line 18, in <module>
raise ImportError("Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
When I try to import numpy I get the following error:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import numpy
File "C:\Users\me\AppData\Local\Continuum\Anaconda3\Lib\site-packages\numpy\__init__.py", line 180, in <module>
from . import add_newdocs
File "C:\Users\me\AppData\Local\Continuum\Anaconda3\Lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Users\me\AppData\Local\Continuum\Anaconda3\Lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Users\me\AppData\Local\Continuum\Anaconda3\Lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Users\me\AppData\Local\Continuum\Anaconda3\Lib\site-packages\numpy\core\__init__.py", line 14, in <module>
from . import multiarray
ImportError: cannot import name 'multiarray'
Can someone help?
try this:
I had the same problem
https://stackoverflow.com/a/40637960/6376603
maybe the above answer will help.
I had similar problem. I uninstalled anaconda from my system completely.
Steps - Delete app, delete anaconda3 folder, empty trash
Then I reinstalled older version of it and it started working perfectly. Maybe it is some kind of bug in the newer version.