I'm currently using miniconda and I want to prevent myself and other users of my machine from installing anything into the base
environment. This is because I want users to be creating virtual environments and installing stuff there. I also don't want my base environment to get bloated.
Is there anyway to do this? I use both conda and pip so I imagine I need to somehow block both of those.
Avoid installing packages into your base Conda environment Conda has a default environment called base that include a Python installation and some core system libraries and dependencies of Conda. It is a “best practice” to avoid installing additional packages into your base software environment.
To exit the virtual environment, use the command conda deactivate . If you run conda info --envs again, there is no * in front of env_name .
Go to Environments tab just below the Home tab and from there we can check what all packages are installed and what is not. It is very easy to install any package through anaconda navigator, simply search the required package, select package and click on apply to install it.
There are two ways to install packages with conda. 1️⃣ From inside an active environment. 2️⃣ From your default shell. The latter requires you to point to the environment you want to install packages in using the same flag (--name or --prefix) that you used to create your environment with.
On installation, conda creates a base environment. However, you can also create your own base environment with packages you frequently use. The - -clone option will create a clone (or snapshot) of the environment, If you need to reproduce an environment across computers with the same operating system, you can generate a spec list.
This setting controls whether or not conda activates your base environment when it first starts up. You'll have the conda command available either way, but without activating the environment, none of the other programs in the environment will be available until the environment is activated with conda activate base.
Conda-pack is a command line tool that archives a conda environment, which includes all the binaries of the packages installed in the environment. This is useful when you want to reproduce an environment with limited or no internet access. All the previous methods download packages from their respective repositories to create an environment.
One option would be to change the write permissions on the directories pip and conda install packages to for the base environments. These locations vary based on your distribution, but you can check by using something like python -c "import setuptools; print(setuptools.__file__)"
. The parent directory to setuputils
will be where the packages get installed by default. Run chmod -w <packages dir>
to remove write permissions. You can always add them back with chmod +w <packages dir>
later, but while they're disabled this should keep you from installing packages there by accident. Unless you haphazardly install packages with sudo
, that is...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With