简体   繁体   English

如何在 anaconda 中将一个模块从“base”环境导入到“tf”环境?

[英]How to import one modules from 'base' environment to 'tf' environment in anaconda?

I have been working with base environment in anaconda till now and had installed all the required python modules/libraries.到目前为止,我一直在anaconda中使用base环境,并安装了所有必需的 python 模块/库。 When I tried to install tensorflow-cpu , I came to know that I have to create another environment to install it from official documentation of anaconda .当我尝试安装tensorflow-cpu时,我才知道我必须从anaconda的官方文档中创建另一个环境来安装它。 Now I have created the new environment named 'tf' to install tensorflow-cpu .现在我创建了名为 'tf' 的新环境来安装tensorflow-cpu Since I can activate only one environment at a time, I don't want want to install all the python modules/libraries again to this new tf environment as it will consume space in memory.由于我一次只能激活一个环境,我不想将所有 python 模块/库再次安装到这个新的tf环境中,因为它会占用 memory 中的空间。

Is there any way, I can use all the modules of base environment to tf environment or vice versa?有什么办法,我可以将base环境的所有模块用于tf环境,反之亦然? Please help in this context!请在这种情况下提供帮助!

It's definitely not a good idea too mix envs.混合环境绝对不是一个好主意。 They were invented to separate dependencies for independent projects.它们被发明来分离独立项目的依赖关系。 Trying to mix them is a "wrong" way of using envs.尝试混合它们是使用环境的“错误”方式。
Also, you don't have to create a new env when installing tf as the docs say, just install it where you want it to be, everything will work just fine.此外,在安装tf时,您不必像文档中所说的那样创建新的环境,只需将其安装在您想要的位置,一切都会正常工作。 The docs recommend you to create one because it's not a good idea to install it into base env.文档建议您创建一个,因为将其安装到base环境中不是一个好主意。

  1. You have an env named tf now.你现在有一个名为tf的环境。 Activate it and install all dependencies you need, then use it in your project.激活它并安装您需要的所有依赖项,然后在您的项目中使用它。
  2. Do not pollute your base env with packages, this one is not supposed to be used for development, rather for conda itself.不要用包污染你的base环境,这个不应该用于开发,而是用于 conda 本身。 Create a new env when you start a new project启动新项目时创建新环境

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM