Add full anaconda package list to existing conda environment - python

I know how to add single packages and I know that the conda create command supports adding a new environment with all anaconda packages installed.
But how can I add all anaconda packages to an existing environment?

I was able to solve the problem as following:
Create a helper env with anaconda: conda create -n env_name anaconda
Activate that env conda activate env_name
Export packages into specification file: conda list --explicit > spec-file.txt
Activate the target environment: activate target_env_name
Import that specification file: conda install --file spec-file.txt

Related

how to manage different module version with the same anaconda?

I am about to program 2 different python projects on my computer, each of them is using a different version of a specific module (PyTorch), as well as modules from the latest anaconda.
I have already installed anaconda and found out that the solution is a virtual environment, however, I don't want to install all anaconda modules for each one of them, but use the already installed anaconda for both of them.
How do I do it?
You can use virtual environment which allows you to install specific packages (with specific version) and/or specific python version.
From the docs,
To create virutal environment called myenv
conda create -n myenv
# Create with specific python version
conda create -n myenv python=3.6
# Create with specific version of python and package
conda carete -n myenv python=3.5 pytorch=1.2
To use a virtual env, you have to activate it.
# Activating myenv
conda activate myenv
To deactivate a env, and fall back to default anaconda env,
# myenv
conda deactivate
conda activate base
# Anaconda default env is called base
To list available virtual env
conda env list
or
conda info --envs

How to change Python version of existing conda virtual environment?

I created a conda environment with Python version 3.8, but it doesn't support matplotlib... So I am looking for something like this to change the Python version: conda env my_env update to python=3.6. Is this possible or do I need to recreate the environment?
I have miniconda installed.
Activate the relevant environment, then install your target python version.
conda activate my_env
conda install python=3.6
Adding to the answer above
conda activate my_env
conda uninstall python
conda install python=x.x
Rebuild a new environment, for example called "myenvi"
conda create --name myenvi python=3.6
And make sure the version by
python --version
After installing all packages, double-check with
conda list -n myenvi
If you already have existing python installation may be in other environment, you can simply use it as base.
Here's what you need to do:
conda activate base
conda install python=3.6
Note: This will activate root environment. and python 3.6 already installed, it will simply replace it.

Conda new environment not empty

I am trying to create a new empty evironment with conda using the command:
conda create -n name python=3.6
Then I activate the environment and export it with
conda env export > environment.yml
I have noticed that the generated yml files contains a lot of pip packages that I guess are installed system wide. I am a ROS user and all the python packages installed by ROS appear there. Is there a way to ensure that those pip packages are not included in my new environment?
Thanks a lot for your help.
Make sure that you created the environment not using
conda env create -n name python=3.6
but using instead the command
conda create -n name python=3.6
Using the first command will link all packages from your base environment.
Also note that your new environment will contain several default packages (such as Python 3.6, pip, etc.) if you use the flag python=3.6 when creating the environment.

Anaconda: Undo conda create

I have anaconda3 using python 3.5. I wanted to experiment with something in python 2.7 so I opened the anaconda command prompt and ran:
conda create -n py27 python=2.7 anaconda
In retrospect that may have been overkill; I didn't need everything in anaconda. I now want to remove it. What I tried
I looked for a uninstall executable for the py27, but couldn't find one
the docs say to: conda - conda uninstall (but that returned: could not locate 'conda--'
I also tried looking in control manager (windows) to see if it was available to uninstall, but it was not
Question: How do I undo conda create -n py27 python=2.7 anaconda? That is to say, I want to go back to my original anaconda3 python 3.5 and no py27.
When you use the create command, you are not replacing your current environment, just creating a new one.
You can see a list of your environments using the following command:
conda info --envs
Then, you can activate a specific environment using (replace py27 by the name of the environment):
On windows: activate py27
On linux: source activate py27
To delete the newly created environment use the following command:
conda remove --name py27 --all
The "all" parameter will also delete any configuration and packages installed with the environment.
Edit
New environments are installed inside the envs folder of your anaconda root so after removing it you can check the folder in case there is anything left, e.g.:
C:\Anaconda3\envs\py27
More info: https://conda.io/docs/user-guide/tasks/manage-environments.html
You only have to delete the environment you do not need any longer:
$ conda env remove -n <env_name>
In your case:
$ conda env remove -n py27
more info here

Python - replace conda environment?

In Anaconda documentation, I've learned that you can:
conda create --name myenv and
conda remove --name myenv --all enviroments.
but then I've learned that only with conda create --name myenv anaconda <--- you have all default packages installed.
so, if I want to keep the name myenv:
can I replace myenv with a new one using the same name (adding all default packages on top of that), or do I necessarily have to remove myenv and create a new one from scratch?
Just activate your environment.
On Windows:
activate myenv
On Unix/Mac OS X:
source activate myenv
and install all packages.
conda install anaconda

Categories

Resources