I have multiple environments under my conda management, as shown below
ss-MacBook-Pro$ conda env list
# conda environments:
#
base * /miniconda2
testenv /miniconda2/envs/testenv
testenvpy3 /miniconda2/envs/testenvpy3
Can I install a package that becomes effective across multiple environments? By reading the documentation, I got the impression that it is NOT possible, because if I do
conda install package-name
it will only get installed into the base environment (the current active environment), but it does not apply to other environments. I remember I can somehow achieve install a package effective to multiple environments under virtualenv before.
Can someone share the suggestion?
conda install only installs packages for the current (activated) environment. Files will be installed in the directory for the specific environment. If you want a specific package in all environments, you'll have to conda install that package for each of your environments (base, testenv, testenvpy3).
To switch between environments you just need to activate the one you switch to. The syntax depends Anaconda version or your OS. For newer Anaconda versions, conda activate <env name> works, and for older versions, source activate <env name> for Unix systems and activate <env name> for Windows.
I'm sure you've looked at this already, but here's a helpful link.
Related
is there a way to specify for a given python package to install in a given conda env vs. the User's python?
I thought that if I did pip install <package> in a given conda environment, this would make the package accessible in that environment.
If I create a conda environment and install pySankey then do conda list, pySankey won't show but instead be installed in /Users/username/Python/3.7/lib/python/site-packages/
The package installs with "Defaulting to user installation because normal site-packages is not writeable". I looked at other stack posts associated with this, but I'm unclear how to modify ~/.bashrc, since my understanding is that ~/.bashrc is not unique to a conda environment. I also checked the path of the conda environment but there's no local as indicated here.
This has happened to me with a couple different packages (eg these packages do not pip install into the conda environment, other do), I'm using pySankey as an example.
thanks!
I have python3.7, python3.8, python3.9, and python3.10 in my ubuntu 22.04 system. I created four virtual environments with each of these versions. They are py37, py38, py39, and py310, respectively.
I have a requirement.txt file and want to install those packages to those four venvs. I can manually activate each environment one by one and then install using python3 -m pip install -r requirement.txt.
My question is, is there a way from the terminal I can activate, install and deactivate the venvs using a loop. I am looking for a python solution, though shell scripts are also welcome.
Thanks
I am using a CentOs Distribution of Linux and have miniconda already installed along with conda environments that I created with it. I am trying to install anaconda now. Do I have to uninstall miniconda first? I have some environments that I created with miniconda that I would like to keep. Is it possible to keep those environments if I uninstall it? The reason I need anaconda is I'd like to create environments inside my singularity container. How would it be possible to keep both? Thanks.
Both Miniconda and Anaconda include Conda, so no need to install both. Given either, a new environment with all the Anaconda distribution packages can be created using
conda create --name my_anaconda_env anaconda
Note that Python versions can be specified as part of this, e.g.,
conda create --name my_anaconda37_env anaconda python=3.7
I have python3.7 installed on my windows 10 laptop
But i need python3.6 for a specific project
Can i install it in virtualenv which will override python3.7 in that environment?
I don't know whether this may be an appropriate solution for you. But this is what I generally follow. Just install Anaconda in your system and create an environment according to your needs. For your case create an environment for Python 3.6.
conda create --name py36 python=3.6
//This lines will create an environment named py36
You then install libraries according to your needs in that environment. You work in that environment without interfering with the libraries of the other environment. To use anaconda kindly follow Anaconda cheatsheet. You will get everything that you need.
It is well known that Anaconda installation on macOS can cause trouble with other widely used package/environment managers like Homebrew, Pyenv, Virtualenv, etc.
The majority of the solutions I've found are 'Anaconda-centric', i.e. using Anaconda as the main python manager and setup conda env for homebrew etc.
However, I am looking for a solution that's kind of 'Homebrew-centric', and setup Anaconda as a compliment. Anaconda should be set up in a way that when ever conda is used, it will work with its own Python, own packages. And leave the rest of system untouched.
The motivation for such solution is because that, for example, when one's main work-flow use homebrew Python3 (python3), homebrew pip (pip3) and Pyenv (pyenv) with requirement.txt. And occasionally using Anaconda when a project is required.
Rather than using Anaconda I would suggest using Miniconda, which includes only Python and conda (and a few support packages). Miniconda does not include all of the packages in Anaconda by default, but they can all be installed (with conda install anaconda). Once you download Miniconda, you can install it into your home folder at /Users/username/miniconda3. During the installation, you will be asked if you want to add some initialization code to your .bash_profile. Either choose yes or (if you chose no), then you can run
/Users/username/miniconda3/bin/conda init
to add the conda initialization to your .bash_profile. By default, this will activate the base environment, so you can change the default setting so the environment is not activated by default:
conda config --set auto_activate_base false
You'll probably need to open a new terminal so the conda command is available. Then, when you want to use a conda environment, you can conda activate that environment, but otherwise, conda's Python should not be on your PATH.