Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to share an Anaconda Python environment between multiple users?

I have Anaconda 5.1 Python distribution installed (by the system admin) on Windows 10, for all users. I can create an environment and then view the available environments:

λ conda create --name py35 python=3.5 anaconda

...

λ conda env list
# conda environments:
#
base    *  C:\ProgramData\Anaconda3
py35       C:\Users\<my-user-name>\AppData\Local\conda\conda\envs\py35

When I log in as a different user, however, only the base environment is visible/available. How can I create an environment and make it available to all users of the system?

The documentation discusses multi-user installations, but I cannot see how to make environments available to other users.

like image 993
4Oh4 Avatar asked Feb 19 '18 17:02

4Oh4


People also ask

Can you copy an Anaconda environment?

Moving, Moving, Moving. Conda provides multiple ways of reproducing project environments. Creating a clone of an environment can provide a custom base environment or snapshot of the environment. Spec list and conda-pack create platform and operating system specific copies of an environment.

Does Anaconda support multiple Python environment?

Conda treats Python the same as any other package, so it is easy to manage and update multiple installations. Anaconda supports Python 3.7, 3.8, 3.9 and 3.10.

How do I create an environment with Python in Anaconda?

Use the terminal or an Anaconda Prompt for the following steps: To create an environment: Replace myenv with the environment name. When conda asks you to proceed, type y: proceed ( [y]/n)? This creates the myenv environment in /envs/. No packages will be installed in this environment. To create an environment with a specific version of Python:

How to set up Conda in Anaconda?

1 Check if conda is installed in your path. Open up the anaconda command prompt. ... 2 Update the conda environment. Enter the following in the anaconda prompt. 3 Set up the virtual environment. Type conda search “^python$” to see the list of available python versions. ... 4 Activating the virtual environment. ...

How do I create a shared environment in conda?

conda env create -f environment.yml If you really want to use a shared environment where every user can access, then you have to use the -p or --prefix option in your create: conda create -p C:/full/public/path/to/py35 python=3.5 And then instruct your users to add the public path (C:/full/public/path/to) to their conda config file.

Can I use Anaconda with other Python distributions?

Anaconda is also useful as a general purpose Python distribution. But Anaconda comes with its share of snares and subtleties. What if you’re using Anaconda alongside other Python distributions, and you don’t want them stepping on each other’s toes? How do you integrate Anaconda effectively with your other Python tooling, like IDEs?


Video Answer


2 Answers

I would shy away from sharing environments with other users, because if they don't know what they are doing, they could add packages that could conflict with other packages and/or even delete packages that another user might need. The preferred approach is that after you have created an environment, you export it as a yml file:

conda env export > environment.yml

Then you send the users the yml file and have them build their own environment using the yml:

conda env create -f environment.yml

If you really want to use a shared environment where every user can access, then you have to use the -p or --prefix option in your create:

conda create -p C:/full/public/path/to/py35 python=3.5

And then instruct your users to add the public path (C:/full/public/path/to) to their conda config file. Then, they should be able to see the environment when running conda env list.

like image 146
Scratch'N'Purr Avatar answered Oct 14 '22 15:10

Scratch'N'Purr


The key here is adding the path to the folder containing the environment(s) to the user's conda configuration file .condarc. Like this:

envs_dirs:
  - C:\full\path\to\environments\folder

This makes all the environments (subfolders within) available to the user. It does not appear to be possible to make a specific, named environment available.

As has been pointed out, you can create an environment in a specific location using the -p flag, and then add the parent directory to the configuration file, but this is not a requirement. This may be useful, however, to avoid permissions errors if sharing environments that exists in protected user areas.

On Windows 10, my user configuration file was in C:\Users\<my-user-name>\, and I just added the above text to the end of it.

like image 28
4Oh4 Avatar answered Oct 14 '22 14:10

4Oh4