问题描述
在tensorflow安装指南中,我应该使用环境"来安装tensorflow: https ://www.tensorflow.org/install/install_windows#installing_with_anaconda
In tensorflow installation guide it is said, that I should use "environment" to install tensorflow: https://www.tensorflow.org/install/install_windows#installing_with_anaconda
为什么?我不能随便安装pip吗?
Why? Can't I just install with pip?
如果安装在环境中,我每次使用tensorflow时都应该激活"它吗?
If installed with environment, should I "activate" it each time I use tensorflow?
如果我在keras和/或PyCharm等其他事物中使用tensorflow,那么我该如何激活环境?
If I use tensorflow from within other thing like keras and/or PyCharm, then how can I activate environment?
推荐答案
问题与Windows有关.我假设您使用anaconda安装了python.然后,您有一个默认环境,称为root.您可以根据需要创建任意多个环境,将每个环境都视为单独的python安装.使用conda或pip会在您当前的安装中安装东西. Conda的东西是经过预编译的,可以在您的机器/anaconda环境中使用,而pip的东西通常是在现场编译的.我认为编译tensorflow可能并不简单...
The question is about Windows. I assume you installed python using anaconda. Then you have a default environment, called root. You can create as many environments as you want, think of each as a separate installation of python. Using conda or pip installs stuff at your current installation. Conda stuff is kind of pre-compiled to work with your machine/anaconda environment, while pip stuff is usually compiled on the spot. I assume compiling tensorflow might not be completely trivial...
激活"从一个环境更改为另一个环境,因此,除非您具有多个环境,否则就不需要它.您可以在命令提示符下运行所有这些命令.
'Activate' changes from one environment to the other, so unless you have multiple environments you shouldn't need it. You run all these on command prompt.
最重要的是,除非您有多个环境(强烈建议您使用它,以便您可以尝试其他操作),否则看不到您使用Activate.将tensorflow和keras安装在您拥有的同一个且唯一的根环境中.您应该能够访问这两者(如果有依赖关系,也可以只安装keras即可安装tensorflow)
Bottom line is, unless you have multiple environments (I highly recommend it so you can try different things) I cannot see you using activate. Install tensorflow and keras on the same one and only root environment you have. You should be able to access both (it is also possible just installing keras would install tensorflow, if its a dependancy)
如果没有提示,则为默认的根环境.您可以使用以下命令查看所有环境:conda info --envs但是,除非您创建某些环境(例如,使用conda create --name py Python = 2),否则您可能只有root用户.环境的优点之一是您可以使用Python = 2(最新的python 2),使用Python = 3,使用Python = 2.7等
If you see no prompt, it is the default, root environment. You can see all your environments with: conda info --envs But unless you create some environment (using e.g. conda create --name py Python=2) you probably only have root. One of the nice things with environments is you can have one with Python=2 (latest python 2), one with Python=3, another with Python=2.7 etc
在后续操作中,如果您有多个环境,则可以通过更改解释器在Pycharm上在它们之间进行切换.在图片上,您看到我选择了py2_olv
On your follow-up, If you have multiple environments, you can switch between them on Pycharm by changing the interpreter. On the image you see me selecting e.g. py2_olv
这篇关于为什么要使用Anaconda环境在Windows上安装tensorflow?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!