Anaconda installation and Python environment creation under Linux offline state

1 Download and Installation Instructions

  • download

    • Download address: https://repo.anaconda.com/archive/
    • Version: Here, the anaconda version 2020.11 is used as an example, and the python version it carries is 3.8.5.
    • Download: Find and download the Anaconda3-2020.11-Linux-x86_64.sh file in the above link, or enter https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh to directly download the installation package
  • File upload
    Upload the downloaded installation package to the file folder in the offline linux directory, upload it to the files folder here.

2 Anaconda installation

  • Copy the cuda toolkit installer in the files folder to the software folder

    cp files/Anaconda3-2020.11-Linux-x86_64.sh software/
    

    Enter the directory where the cuda toolkit installer is placed (assuming the current directory is the user's home directory)

    cd software/
    # 查看当前目录
    pwd
    # 输出内容为:/data/users/CHDHPC/2017901437/software/
    

    Execute ls to view the files in the current directory:
    insert image description here

  • Modify the running permissions of the Anaconda toolkit installer

    chmod +x Anaconda3-2020.11-Linux-x86_64.sh
    
  • Run the Anaconda toolkit installer

    ./Anaconda3-2020.11-Linux-x86_64.sh
    

insert image description here

  • Press the Enter key Enter, the following content appears
    insert image description here

  • Continue to press Enter until the following content appears
    [External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-WUZewh02-1682336415394)(../images/image-20230412145439902.png)]

  • Type yes and press Enter. The following content appears
    insert image description here

  • At this time, you need to select the installation path of anaconda

    • option 1 : Press Enter to install it directly to the path "/data/users/CHDHPC/2017901437/anaconda3";

    • Option 2 : Enter the absolute path of the location to be installed, such as installing to the software directory under the home directory, you can fill in: "/data/users/CHDHPC/2017901437/software/anaconda3"
      insert image description here

  • Press Enter to start the installation. The following content appears to indicate that the installation is complete
    insert image description here

  • Then choose whether to initialize conda and add its environment variables in bashrc

    • Option 1 : Select "Yes", enter yes, press Enter, and the conda initialization will be completed automatically. The bashrc file will automatically add the following environment variables:
      insert image description here

    • option 2 : Select "No", enter no, and press Enter to skip initialization. At this time, you need to manually complete the addition of environment variables:

      • The bashrc file is located in the user's home directory, namely "/data/users/CHHDHPC/2017901437/", so use the cd command to go to this directory

      • Execute vim .bashrcand add the following to it:

        export PATH="/data/users/CHDHPC/2017901437/software/anaconda3/bin:$PATH"
        
      • Execute wqsave and exit

      • Or if you choose no and still want to initialize, you can complete the initialization with the following command:

        source /data/users/CHDHPC/2017901437/software/anaconda3/bin/activate
        conda init
        
  • Execute source ~/.bashrcto make the environment variables take effect; or disconnect the remote connection and re-log in to Gaosu remotely to make the environment variables take effect.

  • The installation is complete
    insert image description here

2.3 Gaoshu creates a virtual environment offline

  • Configure conda (skip this step if you use the conda default path)

    • Execute. conda configA .condarc file will appear in the ~/ directory, which is used to configure personal conda

    • Enter the following configuration content:

      # 断网设备 .condarc
      show_channel_urls: true
      envs_dirs:
        - /data/users/CHDHPC/2017901437/software/myconda/envs
      pkgs_dirs:
        - /data/users/CHDHPC/2017901437/software/myconda/pkgs
      

      That is, specify the environment directory and package directory

  • Download and upload packages (based on another networked linux device)

    • Execute. conda configA .condarc file will appear in the ~/ directory, which is used to configure personal conda

    • Enter the following configuration:

      # 联网设备 .condarc
      show_channel_urls: true
      envs_dirs:
        - /data/myconda/envs
      pkgs_dirs:
        - /data/myconda/pkgs
      
    • download package

      conda create -n 创建的环境名称 python==版本 --download-only
      # --download-only   表示只下载,不创建环境
      
    • upload package

      • When packaging networked devices pkgs, you must ensure that the package is complete. There may be a certain package in the default environment of the networked device, resulting in no repeated downloads. You need to manually pick it out. The package directory is/data/myconda/pkgs
      • Upload the packaged pkgs package to the user's home directory of Gaosuan using remote software
      • Copy the files in the uploaded pkgs to the pkgs directory of the home directory, the output path is/data/users/CHDHPC/2017901437/software/myconda/pkgs
  • Download and upload packages (based on another networked Windows device)

    • download package

      conda create -n 创建的环境名称 python==版本 --download-only
      # --download-only   表示只下载,不创建环境
      
    • upload package

      • Same as above, pack the networked device pkgs, and then upload the packed pkgs package to the Gaosuan user’s home directory using remote software
      • Copy the files in the uploaded pkgs to the pkgs directory of the home directory, the output path is/data/users/CHDHPC/2017901437/software/myconda/pkgs
  • Create a new virtual environment in Gaoshu anaconda

    conda create -n 创建的环境名称 python==版本 --offline
    
  • activate and verify

    • activation

      # 激活(是否需要看情况)
      source activate
      # 切换环境
      conda activate 创建的环境名称
      
    • verify

      # 查看python版本
      python --version
      

Guess you like

Origin blog.csdn.net/qq_43522889/article/details/130350255