How does conda-env list / conda info --envs find environments?

2024/10/7 10:18:17

I've been experimenting with anaconda/miniconda because my users use structural biology programs installed with miniconda and none of the authors A) take into account that there might be other miniconda applications B) that their programs will be used in a multi-user environment.

So, using Arch linux, first I installed anaconda (version 4.5.12) , and then using my own account, created a couple of test environments:

conda create -n snakes
conda create -n sharks

I then (completely) uninstalled anaconda and installed miniconda (also version 4.5.12) and then created another environment in a non-standard location as root:

# conda create -p /usr/local/miniconda/pyem

Here's where things get weird. When I list the environments as the root user, I see not only the default and the one I just created, but also the ones I created previously using my user account!

[root@lizard /]# conda info --envs
# conda environments:
#/home/cnsit/.conda/envs/sharks/home/cnsit/.conda/envs/snakes
base                  *  /opt/miniconda3/usr/local/miniconda/pyem

(The conda-env list command gives the same output.)

So, question: how is conda finding environments created by a different user? Moreover, when the entire parent directory of the original instance of conda has been removed and replaced by one in an entirely different location (so no local environments.txt file could be cataloging this.

Answer

The code for the info command is contained in the cli.main_info module, and the relevant code for this case is here. This imports the function from over here that (among other things) reads the configuration value envs_dirs. You can find out the value of this configuration value on your system by running

conda config --show envs_dirs

I expect this will show you the user directories for environments as being searched.

https://en.xdnf.cn/q/70254.html

Related Q&A

Updating a large number of entities in a datastore on Google App Engine

I would like to perform a small operation on all entities of a specific kind and rewrite them to the datastore. I currently have 20,000 entities of this kind but would like a solution that would scale …

Is there a neater alternative to `except: pass`?

I had a function that returned a random member of several groups in order of preference. It went something like this:def get_random_foo_or_bar():"Id rather have a foo than a bar."if there_are…

Get a permutation as a function of a unique given index in O(n)

I would like to have a function get_permutation that, given a list l and an index i, returns a permutation of l such that the permutations are unique for all i bigger than 0 and lower than n! (where n …

How to generate Bitcoin keys/addresses from a seed in Python?

I am trying to create a set of public/private keys from a mnemonic based on BIP0039. I am working in Python.Here is the code I have so far:from mnemonic import Mnemonic mnemon = Mnemonic(english) words…

NumPy - Set values in structured array based on other values in structured array

I have a structured NumPy array:a = numpy.zeros((10, 10), dtype=[("x", int),("y", str)])I want to set values in a["y"] to either "hello" if the corresponding val…

numpy.disutils.system_info.NotFoundError: no lapack/blas resources found

Problem: Linking numpy to correct Linear Algebra libraries. Process is so complicated that I might be looking for the solution 6th time and I have no idea whats going wrong. I am on Ubuntu 12.04.5. I …

Opencv: Jetmap or colormap to grayscale, reverse applyColorMap()

To convert to colormap, I doimport cv2 im = cv2.imread(test.jpg, cv2.IMREAD_GRAYSCALE) im_color = cv2.applyColorMap(im, cv2.COLORMAP_JET) cv2.imwrite(colormap.jpg, im_color)Then,cv2.imread(colormap.jpg…

Get file modification time to nanosecond precision

I need to get the full nanosecond-precision modified timestamp for each file in a Python 2 program that walks the filesystem tree. I want to do this in Python itself, because spawning a new subprocess …

`TypeError: argument 2 must be a connection, cursor or None` in Psycopg2

I have a heroku pipeline set up, and have just enabled review apps for it. It is using the same codebase as my staging and production apps, same settings files and everything.When the review app spins …

replace string if length is less than x

I have a dataframe below. a = {Id: [ants, bees, cows, snakes, horses], 2nd Attempts: [10, 12, 15, 14, 0],3rd Attempts: [10, 10, 9, 11, 10]} a = pd.DataFrame(a) print (a)I want to able add text (-s) to …