使用Virtualenv将Tensorflow安装到Python3

时间:2017-03-17 10:27:34

标签: python tensorflow virtualenv

我正在尝试使用virtualenv将tensorflow安装到python3,遵循此网页上的说明。我正在使用Mac Sierra,python2.7和python3.5都在我的机器上。 https://www.tensorflow.org/install/install_mac#installing_with_virtualenv

使用此方法对python2.7工作正常,但python3.5 失败。以下是我发出的错误消息pip3 install --upgrade tensorflow

Installing collected packages: tensorflow, setuptools
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 742, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 831, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 1032, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 346, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 317, in clobber
    ensure_dir(destdir)
  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/tensorflow-1.0.1.dist-info'
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:1)

必须在创建时指定用于virtualenv的解释器。在这种情况下,使用virtualenv -p python3 ./tensorflow指定python3作为此特定virtualenv的解释器。