mac os install tensorflow

The basic steps of ji follow the binary method

http://www.tensorfly.cn/tfdoc/get_started/os_setup.html said.

 

Method 1: VirtualEnv based installation

# On Mac:

$ sudo easy_install pip # if pip is not installed

$ sudo pip install --upgrade virtualenv

$ virtualenv --system-site-packages ~/tensorflow

$ cd ~/tensorflow

$ source bin/activate # if using bash

$ source bin/activate.csh # if using csh

(tensorflow)$ # The terminal prompt should change

(tensorflow)$ pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl -- this step needs to hang the agent

Can test:

 

(tensorflow)$ cd tensorflow/models/image/mnist

(tensorflow)$ python convolutional.py

 

# When finished using TensorFlow

(tensorflow)$ deactivate # deactivate virtualenv

 

$ # Your command prompt will be restored

 

Method 2: Direct installation

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

 

In this way, the six version will be too low, but the mac cannot allow the six to be upgraded.

 

Solution

Turn off the sip feature:

1. Restart the MAC, press and hold Command+R during the restart to enter safe mode

2. Open the terminal in the top menu bar and enter the csrutil disable command to disable the SIP security feature (if you want to enable sip, use csrutil

 enable command)

3. Restart the MAC and it will be OK

Remember to restart sip after the update

 

When I installed it, I took a detour. The first installation suggested that six 1.4.1 could not be uninstalled. I directly used 

 

pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl --ignore-installed six

The result is that the installation is successful, but the import tensorflow in python China reports an error, and the six reference reports an error.

At this point I turn off sip and try again

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

It prompts that the six version 1.11.0 is successfully installed, but in the python interactive interface of the system,

import tensorflow still reports an error.

Import six in python, see the version or 1.4.1 through help(six) and finally found

In the system library six.py (/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py) or 1.4.1

Manually backup 1.4.1 six.py and copy /Library/Python/2.7/site-packages/six.py to /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/

python import tensorflow problem solved again

 

 

Finally, it is recommended to install based on VirtualEnv, which does not require the east system library, and all are not affected.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326480787&siteId=291194637