Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python package is missing ModuleSpec in tensorflow.__spec__ in tf 1.14.0 #30028

Closed
JonasAmrich opened this issue Jun 21, 2019 · 8 comments
Closed
Assignees
Labels
comp:apis Highlevel API related issues type:bug Bug

Comments

@JonasAmrich
Copy link

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): no
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux-4.9.125-linuxkit-x86_64-with-Ubuntu-18.04-bionic
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: no
  • TensorFlow installed from (source or binary): preinstalled in docker image
  • TensorFlow version (use command below): v1.14.0-rc1-22-gaf24dc91b5 1.14.0
  • Python version: 3.6.8
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory:

Describe the current behavior

In TF 1.14.0 the module spec in tensorflow.__spec__ is None:

>>> import tensorflow
>>> print(tensorflow.__spec__)
None

Describe the expected behavior

This is different from tf 1.13.1 where it works as expected:

>>> import tensorflow
>>> print(tensorflow.__spec__)
ModuleSpec(name='tensorflow', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7f038cfc3cf8>, origin='/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py', submodule_search_locations=['/usr/local/lib/python3.5/dist-packages/tensorflow'])

Missing spec causes some problems, e.g. pkgutil now fails when trying to find tensorflow. Note that the first call to find_loader is successful, it only fails after tensorflow is imported:

Python 3.6.8 (default, Jan 14 2019, 11:02:34) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pkgutil
>>> pkgutil.find_loader('tensorflow')
<_frozen_importlib_external.SourceFileLoader object at 0x7f62372c7160>
>>> import tensorflow
>>> pkgutil.find_loader('tensorflow')
Traceback (most recent call last):
  File "/usr/lib/python3.6/pkgutil.py", line 490, in find_loader
    spec = importlib.util.find_spec(fullname)
  File "/usr/lib/python3.6/importlib/util.py", line 102, in find_spec
    raise ValueError('{}.__spec__ is None'.format(name))
ValueError: tensorflow.__spec__ is None

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/pkgutil.py", line 496, in find_loader
    raise ImportError(msg.format(fullname, type(ex), ex)) from ex
ImportError: Error while finding loader for 'tensorflow' (<class 'ValueError'>: tensorflow.__spec__ is None)

Code to reproduce the issue
See above

Other info / logs

I've tested this using official tf docker image (tensorflow/tensorflow:1.14.0-py3) and also using python docker image (python:3.6) with tensorflow installed with pip.

@hhsecond
Copy link

importlib throws the same error. Can't do custom imports in 1.14.

Traceback (most recent call last):
  File "path/test/test_model.py", line 62, in testTFGraph
    save_tensorflow(sess, path, output=['output'])
  File "path/model.py", line 55, in save_tensorflow
    if not is_installed('tensorflow'):
  File "path/_util.py", line 18, in is_installed
    if importlib.util.find_spec(p) is None:
  File "path/lib/python3.7/importlib/util.py", line 114, in find_spec
    raise ValueError('{}.__spec__ is None'.format(name))
ValueError: tensorflow.__spec__ is None

@mihaimaruseac
Copy link
Collaborator

Another data point: this also happens in nightly

@annarev
Copy link
Contributor

annarev commented Jun 27, 2019

Sorry for the breakage! This is caused by adding a module wrapper that prints deprecation messages. I will send a change to fix it.

pull bot pushed a commit to testkevinbonz/tensorflow that referenced this issue Jun 28, 2019
tensorflow#30184,
tensorflow#30028.
Also, while at it, reducing maximum deprecation warnings to 1 per module to reduce amount of spam.

PiperOrigin-RevId: 255628386
@ymodak
Copy link
Contributor

ymodak commented Jul 9, 2019

Closing this issue since the associated PR has been merged. Thanks!

@ymodak ymodak closed this as completed Jul 9, 2019
@tensorflow-bot
Copy link

tensorflow-bot bot commented Jul 9, 2019

Are you satisfied with the resolution of your issue?
Yes
No

@SumNeuron
Copy link

Is there a work around in the mean time?

@mihaimaruseac
Copy link
Collaborator

We'll get the 1.14.1 patch release this week.

@mihaimaruseac
Copy link
Collaborator

Update: Instead of a 1.14.1 patch release, we will get a 1.15 version in a few weeks. Sorry for the extra delay this causes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:apis Highlevel API related issues type:bug Bug
Projects
None yet
Development

No branches or pull requests

7 participants