Search code examples
pythontensorflowanacondaenvironmentpython-module

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. 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. Now I have created the new environment named 'tf' to install 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.

Is there any way, I can use all the modules of base environment to tf environment or vice versa? Please help in this context!


Solution

  • 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. The docs recommend you to create one because it's not a good idea to install it into base env.

    1. You have an env named tf now. 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. Create a new env when you start a new project