tensorflow: TensorFlow upgrade to 1.0.0 breaking import

On the Mac OS X El Capitan V 10.11.6 using python 2.7.11 with anaconda

when I run this code:

pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl

I get a working version of tensorflow 0.9.0. import tensorflow in python throws no errors.

I type in the command:

pip install --upgrade tensorflow

I get a successful install

Collecting tensorflow
  Using cached tensorflow-1.0.0-cp27-cp27m-macosx_10_11_x86_64.whl
Requirement already up-to-date: mock>=2.0.0 in ./anaconda/lib/python2.7/site-packages (from tensorflow)
Requirement already up-to-date: six>=1.10.0 in ./anaconda/lib/python2.7/site-packages (from tensorflow)
Requirement already up-to-date: numpy>=1.11.0 in ./anaconda/lib/python2.7/site-packages (from tensorflow)
Collecting protobuf>=3.1.0 (from tensorflow)
  Using cached protobuf-3.2.0-py2.py3-none-any.whl
Requirement already up-to-date: wheel in ./anaconda/lib/python2.7/site-packages (from tensorflow)
Requirement already up-to-date: funcsigs>=1; python_version < "3.3" in ./anaconda/lib/python2.7/site-packages (from mock>=2.0.0->tensorflow)
Requirement already up-to-date: pbr>=0.11 in ./anaconda/lib/python2.7/site-packages (from mock>=2.0.0->tensorflow)
Requirement already up-to-date: setuptools in ./anaconda/lib/python2.7/site-packages (from protobuf>=3.1.0->tensorflow)
Requirement already up-to-date: appdirs>=1.4.0 in ./anaconda/lib/python2.7/site-packages (from setuptools->protobuf>=3.1.0->tensorflow)
Requirement already up-to-date: packaging>=16.8 in ./anaconda/lib/python2.7/site-packages (from setuptools->protobuf>=3.1.0->tensorflow)
Requirement already up-to-date: pyparsing in ./anaconda/lib/python2.7/site-packages (from packaging>=16.8->setuptools->protobuf>=3.1.0->tensorflow)
Installing collected packages: protobuf, tensorflow
  Found existing installation: protobuf 3.0.0b2
    Uninstalling protobuf-3.0.0b2:
      Successfully uninstalled protobuf-3.0.0b2
  Found existing installation: tensorflow 0.9.0
    Uninstalling tensorflow-0.9.0:
      Successfully uninstalled tensorflow-0.9.0
Successfully installed protobuf-3.2.0 tensorflow-1.0.0

and I get a broken import statement in python (… modify dir names)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "../anaconda/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "../anaconda/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 124, in <module>
    from tensorflow.python.platform import test
  File "../anaconda/lib/python2.7/site-packages/tensorflow/python/platform/test.py", line 83, in <module>
    import mock                # pylint: disable=g-import-not-at-top,unused-import
  File "../anaconda/lib/python2.7/site-packages/mock/__init__.py", line 2, in <module>
    import mock.mock as _mock
  File "../anaconda/lib/python2.7/site-packages/mock/mock.py", line 71, in <module>
    _v = VersionInfo('mock').semantic_version()
  File "../anaconda/lib/python2.7/site-packages/pbr/version.py", line 460, in semantic_version
    self._semantic = self._get_version_from_pkg_resources()
  File "../anaconda/lib/python2.7/site-packages/pbr/version.py", line 447, in _get_version_from_pkg_resources
    result_string = packaging.get_version(self.package)
  File "../anaconda/lib/python2.7/site-packages/pbr/packaging.py", line 750, in get_version
    name=package_name))
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name mock was given, but was not able to be found.

when I import again in the same interface, I get a different error which repeats if I do it anymore

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "../anaconda/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "../anaconda/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 72, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "../anaconda/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 61, in <module>
    from tensorflow.python import pywrap_tensorflow
ImportError: cannot import name pywrap_tensorflow


Failed to load the native TensorFlow runtime.

See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 26 (15 by maintainers)

Commits related to this issue

Most upvoted comments

export PBR_VERSION=‘your pbr version’, it’s will be worked, but i don’t know why VersionInfo(‘mock’) is wrong, maybe setup.cfg in mock has some problem.

try this pip install -U protobuf==3.0.0b2 and in my case it solved the problem

Got it!!!

So, I tried the virtual environment conda install. It worked (but was buggy, as noted). Then I thought “maybe this will work on my native system”. It did. Now I can access tensorflow 1.0.0 from my system. Many thanks!

conda install -c conda-forge tensorflow