按照此处的说明验证我的tensorflow安装时: https://www.tensorflow.org/install/install_mac#ValidateYourInstallation
导入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
我在两台不同的Mac上遇到过这个问题;这个安装是在virtualenv,另一个安装python直接。我使用sudo -H在Macports上从头开始安装了python 3,readline和pip。
我还使用sudo port select --set python python36将python3设置为默认值(pip3相同)。
这里是tf的virtualenv安装: 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