Tensorflow installation error on Mac OSX Sierra

2019-08-17 12:50发布

问题:

When verifying my tensorflow installation as per the instructions here: https://www.tensorflow.org/install/install_mac#ValidateYourInstallation

I get the following error message immediately after importing tf:

(tensorflow) Davids-iMac:~ david$ python
Python 3.6.1 (default, Apr 24 2017, 06:18:27) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
python(12966,0x7fffa84273c0) malloc: *** error for object 0x10b235eb0: 
pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

I have had this problem on two different Macs; this installation was in a virtualenv, the other installation python directly. I installed python 3, readline and pip from scratch with Macports using sudo -H.

I also used sudo port select --set python python36 to set python3 to be the default (same for pip3).

Any hints where I went wrong greatly appreciated.

Here the virtualenv installation of tf: cd /opt/local/bin sudo ln -s /opt/local/Library/Frameworks/Python.framework/Versions/3.6/bin/virtualenv cd

virtualenv --system-site-packages -p python3 tensorflow/
The path python3 (from --python=python3) does not exist
Davids-iMac:~ david$ virtualenv --system-site-packages -p python tensorflow/
Running virtualenv with interpreter /opt/local/bin/python
Using base prefix '/opt/local/Library/Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/david/tensorflow/bin/python
Installing setuptools, pip, wheel...done.
Davids-iMac:~ david$ source ~/tensorflow/bin/activate
(tensorflow) Davids-iMac:~ david$ pip -V
pip 9.0.1 from /Users/david/tensorflow/lib/python3.6/site-packages     (python 3.6)
(tensorflow) Davids-iMac:~ david$ pip install --upgrade tensorflow
Collecting tensorflow
  Downloading tensorflow-1.1.0-cp36-cp36m-macosx_10_11_x86_64.whl (31.3MB)
    100% |████████████████████████████████| 31.3MB 49kB/s 
Collecting numpy>=1.11.0 (from tensorflow)
  Downloading numpy-1.12.1-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.4MB)
    100% |████████████████████████████████| 4.4MB 319kB/s 
Requirement already up-to-date: wheel>=0.26 in ./tensorflow/lib/python3.6/site-packages (from tensorflow)
Collecting werkzeug>=0.11.10 (from tensorflow)
  Downloading Werkzeug-0.12.2-py2.py3-none-any.whl (312kB)
    100% |████████████████████████████████| 317kB 3.0MB/s 
Collecting six>=1.10.0 (from tensorflow)
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting protobuf>=3.2.0 (from tensorflow)
  Downloading protobuf-3.3.0.tar.gz (271kB)
    100% |████████████████████████████████| 276kB 3.2MB/s 
Requirement already up-to-date: setuptools in ./tensorflow/lib/python3.6/site-packages (from protobuf>=3.2.0->tensorflow)
Building wheels for collected packages: protobuf
  Running setup.py bdist_wheel for protobuf ... done
  Stored in directory: /Users/david/Library/Caches/pip/wheels/1b/42/a0/4c7343df5b629ec9c75655468dce7652b28026896b0209ba55
Successfully built protobuf
Installing collected packages: numpy, werkzeug, six, protobuf, tensorflow
Successfully installed numpy-1.12.1 protobuf-3.3.0 six-1.10.0 tensorflow-1.1.0 werkzeug-0.12.2
(tensorflow) Davids-iMac:~ david$ python
Python 3.6.1 (default, Apr 24 2017, 06:18:27) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
python(12966,0x7fffa84273c0) malloc: *** error for object 0x10b235eb0:     pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6