Miniconda installation tutorial [Linux]

Preface

Recently, I need to deploy a Python program on a Linux server, but the Python version that comes with the server is inconsistent with the Python version used when the program was developed. At the same time, in order to avoid the impact of program dependency packages on the system Python environment package, I decided to use a virtual environment to run the program.

Why choose Miniconda?

First, let’s take a look at the differences between pip, conda, virtualenv, Anaconda, and Miniconda.
The differences between Anaconda and conda, pip and conda - Zhihu

  1. Pip is a general manager of Python packages. It can only manage python packages. It is usually used to install packages published on the Python Package Index (PyPI). Packages can be installed in any environment.
  2. Conda is a language-agnostic cross-platform package and environment manager, not only suitable for managing Python packages, but also a general package management tool. Conda can be used to create and manage packages and dependencies of any type written in any language. But if we want to install Python packages in an existing system Python environment, conda cannot help us, because it can only install packages in the conda environment.
  3. Virtualenv is a Python package that can create a virtual environment, but its default Python version is the same as the system python version, and it cannot be run by changing the python version.
  4. Anaconda and Miniconda are both conda distributions, just like debian and ubuntu are Linux distributions.
    • Anaconda is developed by Anaconda Company, a complete distribution containing the core software in the PyData ecosystem. It includes Python itself and binaries of hundreds of third-party open source projects, such as conda, numpy, scipy, ipython, etc.
    • Miniconda is essentially an installer used to install an empty conda environment. It only contains Conda and Conda's dependencies, but does not include the packages listed in the previous paragraph. It is very small.

Since we only run some scripts on the server, we chose lightweight Miniconda to create the environment.

Miniconda download and installation

Miniconda official website download address
Tsinghua University open source software mirror station download address

Explanation about Miniconda version

Insert image description here

  • Miniconda[2/3]: Indicates that the python that comes with Miniconda is python2/python3. The example is python3.
  • py310: Indicates the specific version number of python that comes with Miniconda, the example is 3.10
  • 23.1.0-1: Indicates the conda version, the example is 23.1.0-1
  • Linux: system name
  • x86_64: System architecture (Linux can be viewed through uname -a)

Choose to download according to your own needs. If you don’t want to choose, just download the latest version. Be sure to pay attention to the number of the Miniconda suffix and don’t download it by mistake, especially if you download it from the Tsinghua University open source software mirror station.

Download and installation process

The following takes the x86_64 architecture Linux system as an example. For other architectures and systems, please change the download link yourself.

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && bash Miniconda3-latest-Linux-x86_64.sh

Wait a moment and you will be prompted to read the license agreement.


Welcome to Miniconda3 py310_23.3.1-0

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>> 

Press Enter to review all license agreements until prompted Do you accept the license terms?, type yes and press Enter.

Do you accept the license terms? [yes|no]
>>> yes

Set the location to install, you can usually accept the default. Press Enter to confirm the default path (you can enter another path). Here I use the root user for installation and there are no other users in the system, so the default is sufficient. If you use a non-root user to install, it will be installed to the user's home directory by default. It is recommended not to change to the root directory to avoid user permission issues during later use.

Miniconda3 will now be installed into this location:
/root/miniconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/root/miniconda3] >>> 

Do you want to initialize Miniconda3?

Do you wish the installer to initialize Miniconda3
by running conda init? [yes|no]
[no] >>> yes

It is recommended to select yes, which will automatically configure environment variables, etc.

no change     /root/miniconda3/condabin/conda
no change     /root/miniconda3/bin/conda
no change     /root/miniconda3/bin/conda-env
no change     /root/miniconda3/bin/activate
no change     /root/miniconda3/bin/deactivate
no change     /root/miniconda3/etc/profile.d/conda.sh
no change     /root/miniconda3/etc/fish/conf.d/conda.fish
no change     /root/miniconda3/shell/condabin/Conda.psm1
no change     /root/miniconda3/shell/condabin/conda-hook.ps1
no change     /root/miniconda3/lib/python3.10/site-packages/xontrib/conda.xsh
no change     /root/miniconda3/etc/profile.d/conda.csh
modified      /root/.bashrc

==> For changes to take effect, close and re-open your current shell. <==

If you'd prefer that conda's base environment not be activated on startup, 
   set the auto_activate_base parameter to false: 

conda config --set auto_activate_base false

Thank you for installing Miniconda3!

To automatically enter the conda environment when you do not want to enter the system, use the following codeconda config --set auto_activate_base false

common problem

  1. If it appears -bash: conda: command not found, you can try again rebootone after another .
  2. Appears during the installation process Miniconda3-latest-Linux-aarch64.sh:行 358: 3733 非法指令 "$CONDA_EXEC" constructor --prefix "$PREFIX" --extract-conda-pkgs, you can try an earlier version.

Guess you like

Origin blog.csdn.net/qq_42663692/article/details/130462018