Stack Exchange
tensorflow import error :cannot import name 'module_wrapper' from 'tensorflow.python.util'
Code: import tensorflow
Gives the following error
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3296, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-d6579f534729>", line 1, in <module>
    import tensorflow
  File "C:\Users\hp\AppData\Roaming\Python\Python37\site-packages\tensorflow\__init__.py", line 99, in <module>
    from tensorflow_core import *
  File "C:\Users\hp\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\__init__.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "<frozen importlib._bootstrap>", line 1019, in _handle_fromlist
  File "C:\Users\hp\AppData\Roaming\Python\Python37\site-packages\tensorflow\__init__.py", line 50, in __getattr__
    module = self._load()
  File "C:\Users\hp\AppData\Roaming\Python\Python37\site-packages\tensorflow\__init__.py", line 44, in _load
    module = _importlib.import_module(self.__name__)
  File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\hp\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\__init__.py", line 52, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 16, in <module>
    from tensorflow.core.framework import node_def_pb2 as tensorflow_dot_core_dot_framework_dot_node__def__pb2
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\core\framework\node_def_pb2.py", line 16, in <module>
    from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\core\framework\attr_value_pb2.py", line 16, in <module>
    from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\core\framework\tensor_pb2.py", line 16, in <module>
    from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
  File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\core\framework\resource_handle_pb2.py", line 92, in <module>
    __module__ = 'tensorflow.core.framework.resource_handle_pb2'
TypeError: expected bytes, Descriptor found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2033, in showtraceback
    stb = value._render_traceback_()
AttributeError: 'TypeError' object has no attribute '_render_traceback_'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 1095, in get_records
    return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
  File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 313, in wrapped
    return f(*args, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\ultratb.py", line 347, in _fixed_getinnerframes
    records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
  File "C:\ProgramData\Anaconda3\lib\inspect.py", line 1502, in getinnerframes
    frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
  File "C:\ProgramData\Anaconda3\lib\inspect.py", line 1460, in getframeinfo
    filename = getsourcefile(frame) or getfile(frame)
  File "C:\ProgramData\Anaconda3\lib\inspect.py", line 696, in getsourcefile
    if getattr(getmodule(object, filename), '__loader__', None) is not None:
  File "C:\ProgramData\Anaconda3\lib\inspect.py", line 733, in getmodule
    if ismodule(module) and hasattr(module, '__file__'):
  File "C:\Users\hp\AppData\Roaming\Python\Python37\site-packages\tensorflow\__init__.py", line 50, in __getattr__
    module = self._load()
  File "C:\Users\hp\AppData\Roaming\Python\Python37\site-packages\tensorflow\__init__.py", line 44, in _load
    module = _importlib.import_module(self.__name__)
  File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\hp\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\__init__.py", line 32, in <module>
    from tensorflow._api.v1 import app
  File "C:\Users\hp\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\_api\v1\app\__init__.py", line 14, in <module>
    from tensorflow.python.util import module_wrapper as _module_wrapper
ImportError: cannot import name 'module_wrapper' from 'tensorflow.python.util' (C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\util\__init__.py)

I have installed tensorflow using the following command:

pip install --ignore-installed --upgrade tensorflow-gpu==1.15.0

Same issue occurs while importing keras too. Also note that I am new to tensorflow and keras 

Try installing tensorflow with conda.
conda install -c anaconda tensorflow-gpu==1.15.0

If you still have problems you can delete the environment and install with conda the first time.

It worked by running anaconda as administrator. Now am not getting any error for tensorflow but the error is still the same while importing keras
