How to Relocate Your Anaconda or Miniconda Installation on Linux
Sometimes you need to move your Anaconda or Miniconda installation to a different location on disk — maybe you’re out of space on one partition, reorganizing, or setting up a new machine. The catch is that conda hardcodes its install path in many places during setup, so moving the folder alone isn’t enough. This guide walks through doing it safely on Linux.
The one thing to understand
A conda install is not simply relocatable. When you install it, the absolute install path (the “prefix”) gets baked into activation scripts, shebang lines, and config files. So relocating means three things, not one:
move the directory → update your PATH → fix the hardcoded prefixes → verify.
Understanding the task ahead
Relocating conda isn’t as simple as moving the installation directory. The environment configuration and paths hardcoded during installation must be updated correctly so the environment works after the move. Let’s break down the steps.
Step 1: Back up your environment
Before making any changes, back up your existing environment so you can restore it if anything goes wrong.
mkdir ~/conda-backup
cp -r ~/miniconda/* ~/conda-backup/
Note: Replace ~/miniconda with the path to your current Anaconda or Miniconda installation.
Step 2: Move the installation directory
Use mv to move your installation to a new directory. Ensure you have write permissions for the
target.
mv /path/to/current/conda /new/path/to/conda
Here, /path/to/current/conda is your current installation path, and /new/path/to/conda is where
you want to move it.
Step 3: Update environment variables
Update the PATH environment variable in your shell configuration file (.bashrc, .bash_profile,
.zshrc, etc.) to reflect the new directory.
Edit your shell configuration file:
export PATH="/new/path/to/conda/bin:$PATH"
After modifying the file, apply the changes:
source ~/.bashrc # Adjust this command based on your shell
Step 4: Correct hardcoded paths
Some configs and scripts have paths hardcoded to the old location. Update those references.
Navigate to your new Conda directory:
cd /new/path/to/conda
Use find and sed to update hardcoded paths:
find . -type f -exec sed -i 's|/path/to/current/conda|/new/path/to/conda|g' {} +
Adjust the paths as necessary for your situation.
Step 5: Verify the move
After relocating and updating your Conda installation, verify everything works:
conda activate
conda list
Try creating a new environment to further ensure functionality:
conda create --name testenv python=3.8
The mv + sed method is fragile. sed only rewrites the text files it matches; conda also
embeds the old prefix in compiled binaries and length-sensitive placeholders that a naive substitution
can corrupt. For anything important, the more robust route is to not move the install at all —
instead export your environments and recreate them at the new location:
conda env export -n myenv > myenv.yml # per environment
# ...reinstall conda at the new path, then:
conda env create -f myenv.yml
The conda-pack tool is another purpose-built option for
moving an environment between locations or machines. And pick a current Python for new
environments — python=3.8 reached end-of-life in October 2024.
Why isn't mv-ing the conda folder to a new path enough on its own?
Good to know — Anaconda licensing (2024). In March 2024 Anaconda updated its Terms of Service: organizations with more than 200 employees/contractors now need a paid license to use Anaconda’s default channels/repository (academic use at accredited institutions is exempt). If that affects you, a common fix is to use Miniforge — a free installer configured out-of-the-box for the conda-forge channel, which isn’t subject to those payment terms. It’s a drop-in for Miniconda for most workflows.
Recap
Without scrolling up — why is this more than a mv? Relocating conda means:
- Back up first (your safety net),
- Move the directory,
- Update
PATHin your shell rc file, - Fix hardcoded prefixes (or, more robustly, export and recreate environments / use
conda-pack), - Verify with
conda activateandconda list.
The install path is baked in at setup time — respect that and the move goes smoothly. Happy computing!
Where to go next
- Managing conda environments — exporting and recreating environments.
- conda-pack — purpose-built environment relocation.
- Miniforge — the free, conda-forge-default installer.
Disclaimer of liability
The information provided by the Earth Inversion is made available for educational purposes only.
Whilst we endeavor to keep the information up-to-date and correct. Earth Inversion makes no representations or warranties of any kind, express or implied about the completeness, accuracy, reliability, suitability or availability with respect to the website or the information, products, services or related graphics content on the website for any purpose.
UNDER NO CIRCUMSTANCE SHALL WE HAVE ANY LIABILITY TO YOU FOR ANY LOSS OR DAMAGE OF ANY KIND INCURRED AS A RESULT OF THE USE OF THE SITE OR RELIANCE ON ANY INFORMATION PROVIDED ON THE SITE. ANY RELIANCE YOU PLACED ON SUCH MATERIAL IS THEREFORE STRICTLY AT YOUR OWN RISK.
Leave a comment