我可以在机器上同时安装python 2.7和3.5的tensorflow吗? [英] Can I installed tensorflow for python 2.7 and 3.5 on my machine simultaneously?

查看:113
本文介绍了我可以在机器上同时安装python 2.7和3.5的tensorflow吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我通过Anaconda将Python 2.7,Python 3.5,用于Python 3.5的Tensorflow安装在我的计算机(MAC OX)上.我也想在我的机器上安装适用于Python 2.7的Tensorflow.

Currently I have Python 2.7, Python 3.5, Tensorflow for Python 3.5 installed on my machine (MAC OX) via Anaconda. I would like to install Tensorflow for Python 2.7 on my machine as well.

当我尝试"conda create -n tensorflow python = 2.7"时,出现以下错误:"错误:前缀已存在:/Users/x644435/anaconda/envs/tensorflow ".一定是因为我已经为python 3.5安装了tensorflow.

When I tried "conda create -n tensorflow python=2.7", I got the following error: "Error: prefix already exists: /Users/x644435/anaconda/envs/tensorflow". It must be because I have already installed tensorflow for python 3.5.

我可以在我的机器上同时安装python 2.7和3.5的tensorflow吗?如何?

Can I installed tensorflow for python 2.7 and 3.5 on my machine simultaneously? And how?

预先感谢您的帮助.

推荐答案

是的,您可以.创建两个环境(tensorflow,tensorflow3)-正如注释中的@cel所述,环境名称应该是唯一的,仅供参考.

Yes, you can. Create two environments (tensorflow, tensorflow3) -- as @cel mentioned in the comments the environment names should be unique and it is only for your reference.

conda create -n tensorflow python=2.7
conda create -n tensorflow3 python=3.5

现在您有两个使用python2.7和python3.5的环境(尚未安装tensorflow!)

Now you have two environments with python2.7 and python3.5 (tensorflow is not installed yet!)

要做到这一点,请转到每个环境:

In order to do that move to each environment:

source activate <environment-name>

然后基于要使用的python在每个环境中安装Tensorflow.(根据您使用的anaconda版本,您可以使用 pip/pip3 conda-forge ).

Then install Tensorflow in each environment based on the python that is to be used. (based on the anaconda version that you are using you can use pip/pip3 or conda-forge).

如果要使用GPU进行安装,则需要下载并安装 CUDA 库.另外,请记住在 .bashrc

If you are installing with GPU then you need to download and install the CUDA libraries as well. Also, remember to set the environment variables in .bashrc

完成后,您可以使用以下命令查看环境列表:

Once you are done, you can view the list of environments using the command:

conda info --envs

解决特定错误的方法:您收到的错误可能是因为您已经有一个名为" tensorflow "的环境.列出环境以使用 conda info查看现有的Conda环境--envs ,然后使用另一个名称环境名称(例如 tensorflow27 )和 conda create -n tensorflow27 python = 2.7 python 2.7 环境>

SOLUTION TO YOUR SPECIFIC ERROR: The error that you got is probably because you already have an enviroment with the name "tensorflow". List the environments to see your existing Conda Enviroments using conda info --envs and then create the new python 2.7 environment using another name enviroment name like tensorflow27 using conda create -n tensorflow27 python=2.7

注意:在安装ANACONDA时,如果您将 CONDA 路径预先添加到PATH环境变量,然后将其更改为后添加( export PATH ="$ PATH:/home/dennis/anaconda3/bin" )这样安装不会覆盖现有的python安装.(您可以使用 $ whichpython

NOTE: When installing ANACONDA if you pre-appended the CONDA path to the PATH environment variable then change it to post-append (export PATH="$PATH:/home/dennis/anaconda3/bin") so that the installation doesn't override the existing python installation. (you can check this using $which python

测试- 我的计算机上同时安装了两个版本

TESTED - I have both versions installed on my machine

参考: https://conda.io/docs/py2or3.html

这篇关于我可以在机器上同时安装python 2.7和3.5的tensorflow吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆