Python environment names missing - anaconda

If I list my python environments I get a number of unnamed or nameless environments:
(base)$ conda env list
# conda environments:
#
/Users/drf/anaconda
/Users/drf/anaconda/envs/arc
/Users/drf/anaconda/envs/grids
/Users/drf/anaconda/envs/junk
/Users/drf/anaconda/envs/msr
/Users/drf/anaconda/envs/py27
base * /Users/drf/anaconda/envs/py37
/Users/drf/anaconda/envs/pygridgen
/Users/drf/anaconda/envs/pynomo
/Users/drf/anaconda/envs/python3
/Users/drf/anaconda/envs/pytides
/Users/drf/anaconda/envs/pytides3
/Users/drf/anaconda/envs/wxpython
(base)$
I can activate them with their path names, but I can't use shortnames to activate them:
(base) $ conda activate base
(base) $ conda activate /Users/drf/anaconda/envs/arc
(arc) $ conda activate /Users/drf/anaconda/envs/grids
(grids) $ conda activate /Users/drf/anaconda/envs/junk
(junk) $ conda activate /Users/drf/anaconda/envs/msr
(msr) $ conda activate /Users/drf/anaconda/envs/py27
(py27) $ conda activate /Users/drf/anaconda/envs/py37
(py37) $
But I cannot use the shortnames:
(msr)$ conda activate msr
Could not find conda environment: msr
You can list all discoverable environments with `conda info --envs`.
Where are the short names stored and how do I get their utility back?

Make sure you deactivate the activated environments. If you create multiple environments and activate them, they act as child processes and won't recognize the changes in the parent.

I had the same problem when I upgraded conda and anaconda. You need to add the path to your environments using:
conda config --add envs_dirs <path to envs>
For example, after I upgraded I got the following:
(base) $ conda info --envs
# conda environments:
#
/Users/mah/anaconda
/Users/mah/anaconda/envs/ase3
base * /Users/mah/opt/anaconda3
Note that my old environments were in /Users/mah/anaconda… whereas my new install is expecting the environments to be in /Users/mah/opt/anaconda3. The solution in this specific case was:
(base) $ conda config --add envs_dirs /Users/mah/anaconda/envs
(base) $ conda env list
# conda environments:
#
/Users/mah/anaconda
ase3 /Users/mah/anaconda/envs/ase3
base * /Users/mah/opt/anaconda3

Related

library issue related to conda environment not active

When I try to activate my conda environment. I receive the following error:
conda create --name env_test python=3.9.7
conda activate env_test
source $IDPROOT/bin/activate
Could not find conda environment: libigdrcl.so
I am using conda version 22.11.1
Any suggestions on how to resolve ?

conda deactivate command is blocked

[zhuguowei#ecs-299060 ~]$ conda -V
conda 22.9.0
[zhuguowei#ecs-299060 ~]$ conda info --envs
# conda environments:
#
base /data/anaconda3
paddlenlp /data/anaconda3/envs/paddlenlp
ocr /home/zhuguowei/.conda/envs/ocr
[zhuguowei#ecs-299060 ~]$ conda activate ocr
(ocr)
(ocr)
(ocr) conda deactivate
why after activating, only (ocr), I think it should be (ocr) [zhuguowei#ecs-299060 ~], and cannot deactivate it, it is blocked here.

Conda create and conda install

I have used anaconda and miniconda without problem before so I don't know why I am having doubts now about the order to use them as
create an environment with conda create
Activate the environment with conda activate
Install packages with conda install
However, lately I have read one set of instructions in which they do a different order: 1->3->2. That means installing without activating and then activating.
Is this correct? Aren't I installing libraries outside of the environment?
There are multiple ways to create and install packages using conda.
create an environment, activate, install packages
conda create --name env_name python=3.8
conda activate env_name
conda install package_name another_package
create an environment with packages
conda create -n env_name python=3.8 package_name another_package
conda activate env_name
Both methods are correct. In fact, we often use a mix here and there. For example, if I have a project with requirements.txt to be installed with pip but would like it to have pandas and scikit-learn from conda-forge. I will do:
conda create --name ml_api python=3.7 -c conda-forge scikit-learn pandas
conda activate ml_api
python -m pip install -r requirements.txt
At any point, we can add packages in conda environment with
# this will install requests to ml_api env. This can be done at any (env)
conda install --name ml_api requests
# or activate ml_api and install. This will install on activated env
conda activate ml_api
conda install requests
At the end of the day, conda is there to help you. A better flow will depend on your need.
The order you listed them is correct but you only need the conda install packagename before you run the code. So you should first create the conda environment and then activate it. Now when you get ready to run the code the first time, be sure to install your package. This enables you to import the package in your python code.

Anaconda - cannot change active environment

I want to change active environment to cassandra but conda activate command seems to not work:
PS C:\Users\kordi\edek> conda info --envs
# conda environments:
#
C:\ProgramData\Anaconda3
base * C:\Users\kordi\anaconda3
cassandra C:\Users\kordi\anaconda3\envs\cassandra
PS C:\Users\kordi\edek> conda activate cassandra
PS C:\Users\kordi\edek> conda info --envs
# conda environments:
#
C:\ProgramData\Anaconda3
base * C:\Users\kordi\anaconda3
cassandra C:\Users\kordi\anaconda3\envs\cassandra
I've found solution to this problem.
Conda must be first initialized for use with powershell with:
conda init powershell

Spyder not starting AttributeError: module 'asycio' has no attribute 'WindowsSelectorLoopPolicy'

I activate my environment and launch from the conda command line
> activate myenv
> spyder
but I get this error:
Please help
I had to remove my environment conda remove -n envname --all and then conda create -n envname followed by activate envname then conda install -c anaconda spyder.
Seems that there is an issue with my old environments and a recent update I performed.
Now I have to just install the rest of the packages into this environment as clone from previous one wont even allow spyder4 to be installed.

Resources