anaconda search path for environments? - anaconda

Can the anaconda tools that manipulate environments use a search path when looking for environments?
I would like to have a single anaconda installation shared among our group, with a shared set of read-only environments and each user also having their own set of writable personal environments.
Commands like conda env list and conda info -e would have to iterate over an environment search path. So would activate.
Does conda support such an architecture?

I think the answer yes, the envs_dirs configuration parameter can be set in your $HOME/.configrc file (looks like yaml) to change the list of directories searched for environments. You can also set the conda environment search path via the CONDA_ENVS_PATH shell environment variable
https://conda.io/projects/conda/en/latest/user-guide/configuration/use-condarc.html#specify-environment-directories-envs-dirs
However the specific usage scenario outlined above is already handled without modifying any configuration parameters.
If the anaconda install directory is not writable, then conda searches both the shared environments and the environments under $HOME/.conda/envs.
If the anaconda installation directory is writable, the per-user environments in $HOME/envs are silently ignored.

Related

can't activate anaconda venv that do exist

I'm building a website with Django. I built a Django virtual environment with anaconda. A few days ago I have updated the anaconda and after that, I have a problem with activating a virtual environment
When I trying to activate a virtual environment with source activate django, the terminal responds with this message:
Could not find conda environment: django
You can list all discoverable environments with `conda info --envs`.
where apparently there is a virtual environment name 'django'.
When I try conda info --envs on a terminal, it shows:
WARNING: The conda.compat module is deprecated and will be removed in a future release.
# conda environments:
#
/Users/myname/anaconda3/envs/django
base /anaconda
I can't see the first one's name but only directory. However, if I open anaconda navigator and see the list of virtual environments, I can see the environment name 'django', and can activate it with a play button. Also, I can see one more environment name 'anaconda3' which is not even displayed on a terminal by command conda info --envs.
Is there any possible reason for this?

How to create conda env with both name and path specified

OS: Windows 10
It's fine to create an env with either name or path, but it doesn't work with both name and path:
Command:
conda create -name myname --prefix D:\proj\myconda\myname
Error:
conda create: error: argument -p/--prefix: not allowed with argument -n/--name
So how to create an env both with a specific name and path?
The benefit from that is:
It's more convenient to remember a shorter nick name for the env.
It's better to move the path to other drives to save space of the default C system drive in Windows OS.
create a folder wherever you want to keep you environment files, inside the folder run:
conda create --prefix=yourenvname
When you wish to use this env, move to the folder in which you ran the previous command and do:
source activate yourenvname
Or
You can run:
conda create --prefix=path/yourenvname
This will create environment named "yourenvname" in the specified path.
Create conda environment with prefix:
conda create --prefix=path/to/envname # C:\path\to\envname for Windows users
Make sure that the directory specified is added to envs_dirs configuration
conda config --append envs_dirs path/to/envname # again, change if using Windows
Tip: If you are keeping multiple environments under a directory (e.g. /path/to holds multiple conda environments), then you can
conda config --append envs_dirs path/to # again, change if using Windows
and conda will pick up on all environments stored in /path/to.
After this step, conda should recognize that you want to include envname in your named environments. You can verify with:
conda info --envs
which should return something like:
# conda environments:
#
envname /path/to/envname
Finally, to activate the environment, all you should need to do is
conda activate envname # replace envname with your environment name from prefix

Link old envs to conda

We've just migrated from windows7 to windows10 and had a lot of conda environments associated with each their own experiment.
The envs all exist in, say, F:\backup\<experiment_name>\conda\envs\ and as they were created with conda, conda had them registered. Now - with fresh installs of Anaconda3 we've lost the ease of access from conda as conda info --envs only returns:
D:\>conda info --envs
# conda environments:
#
root * D:\bin\anaconda3
What's the easiest way to get the old envs listed as if they were created with conda? There must be a register somewhere that I could update...?
You can add the backup path to envs_dirs in your .condarc config file.
It can be done with:
conda config --append envs_dirs F:\backup\<experiment_name>\conda\envs\
Or just with a manual edit of the file (it's YAML)
envs_dirs:
- D:\bin\anaconda3\envs
- F:\backup\<experiment_name>\conda\envs\
See the official doc for more details.
In my Anaconda installation on Windows 7 there is a file C:\Users\MYUSERNAME\.conda\environments.txt which contains a plain-text list of the paths of all my environments.
If I create a renamed duplicate of one of these environment folders (say to mynewenv) and edit the new path into the environments.txt file, it appears in the output from conda info --envs and I can successfully (as far as I can tell from a quick test) activate the new environment with activate mynewenv.
That may be enough to sort you out, but if there's anything about the old environments that still isn't registered properly then you should be able to export the environment contents to a .yml file and create a brand new copy by specifying that file to the conda env create command.

Require Jupyter Password across all Conda Environments

I am looking to allow users on a cluster to set up their own conda environments.
However, across all users, I want to force them to use a password to log in to Jupyter, regardless of whether or not they are launching from their own conda environment or from the root environment. I know I can globally set conda parameters by modifying the .condarc file in the root Anaconda directory. Is there an equivalent file for globally requiring jupyter password use/setting jupyter configs?
You do not want users to launch their own notebook, if you have a case with multiple users using notebooks you should use JupyterHub. JupyterHub is your solution; JupyterHub has been developed for that, and not using JupyterHub will lead to the same pains a Parsing HTML with RegEx.
JupyterHub works with Containers, if you use container, but works also if you only have conda envs, or just system Python. If you have centralized auth (OAuth/LDAP) JupyterHub hook into that, if you prefer PAM, PAM work. If you have SLURM/MPI, JupyterHub hook into that. If you need to use SSH, JupyterHub can undersand it. There is a full org on GitHub conveniently also named JupyterHub of plugins for JupyterHub to bend it to your will and needs... and if you have a specific case note covered, open a bug report or write a plugin that cover yours, and maybe later it can be added to the org !
So I believe JupyterHub is what you are looking for.
And also, you shouldn't install the notebook in each environment. The notebook server should only be installed once system wide (or once per users sometime). You should only install ipykernel in each env.

installing Oracle Instantclient on Mac OS/X without setting environment variables?

Oracle's instructions specify setting DYLD_LIBRARY_PATH. This makes my application dependent on random users' configuration and is very troublesome to set up.
How can I avoid having to set any environment variables?
http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/intel_macsoft.html
related note for linux: installing Oracle Instantclient on Linux without setting environment variables?
Oracle's instantclient installation instructions specify that the user set DYLD_LIBRARY_PATH. This is very troublesome to manage for multiple users.
To use the instantclient without setting any environment variables:
Download the instantclient distribution from oracle.com. For doing non-java software development, you will need (assuming Oracle 10.2):
instantclient-basic-macosx-10.2.0.4.0.zip
instantclient-sdk-macosx-10.2.0.4.0.zip
instantclient-sqlplus-macosx-10.2.0.4.0.zip
Unzip the three files. This will give you a directory
instantclient_10_2/
Copy the files to /usr, which is one of the default places the dynamic loader searches.
sudo cp instantclient_10_2/sdk/include/*.h /usr/include
sudo cp instantclient_10_2/sqlplus /usr/bin
sudo cp instantclient_10_2/*.dylib /usr/lib
If you use tnsnames.ora, copy it to /etc, which is the default global place the oracle runtime searches.
sudo cp tnsnames.ora /etc
Test with
/usr/bin/sqlplus scott/tiger#myoracle
If your goal is simply to run sqlplus on your MacBook, this might work for you. Remove the DYLD_LIBRARY_PATH environment variable from ~/.bashrc and replace it with an alias:
alias sqlplus="DYLD_LIBRARY_PATH=/Applications/instantclient_11_2 sqlplus"
Blog entry: sqlplus and DYLD_LIBRARY_PATH on Mac OS/X
After much research I found an sustainable solution to this error, that involves editing Apache's launchd configuration .plist file to specify the required DYLD_LIBRARY_PATH, ORACLE_HOME, and LD_LIBRARY_PATH environment variables.
You can view the full answer here: https://stackoverflow.com/a/20670810/1914455

Resources