This is the 18th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021


0 x00. Installation

Since Anaconda has not developed a corresponding release version for M1 chip, miniforge3 is used to temporarily replace it, and there is a quick example.


The following uses Windows and Mac Intel chips (Mac2019 and earlier Versions of Intel) as an example, and Mac M1 as a quick example.

1. Download

There are two ways to download the installation package: the official website and tsinghua Image site. Users can choose a suitable download solution based on their own environment.

  • The latest version of Anaconda can be downloaded from Anaconda’s website, but installation packages are sometimes slow to download.
  • Anaconda Installers

  • Tsinghua mirror station is synchronized to the domestic source, can be quickly downloaded. Sometimes you may not be able to keep up with the latest version of your software. To download the latest version, click on the rightDateButton to sort by time, and then select the appropriate version.
  • Index of /anaconda/archive/

2. Install

Windows

Double-click the installation package to open it

  • In case ofPATHWhen selected, you can select it directly for conveniencePATHEnvironment variable configuration
  • You can also click if you don’t have a local code editorVscodetheInstallButton to install Vscode editor, everything else is one waynextThe default installation is ok.

When the installation is complete, press the Windows Start key on your keyboard. The following application icon indicates that the installation is complete.

Error screen

1. An error occurs when the Anaconda Promot terminal is opened. LoadError: Load Error: In /home/li/.condarc on line xx, column xx. Invalid YAML, go to the directory where the. Condarc file is located, directly delete the file, open the green icon in the figure above, and generate the.

In Windows, the file path is usually C:\Users\ username \.condarc

Mac Intel

Error screen

If you run the conda command on the cli, the conda not found error code may be displayed. In this case, you need to configure environment variables. The configuration file consists of two xxx_profile and xxx_rc, such as. Bash_profile and. Bashrc.

(1) Run the command in the terminal to edit the configuration file

vi ~/.bash_profile
Copy the code

(2) Enter I. Ensure that the Insert prompt is displayed. Add the following content in the displayed window: The content before anaconda3/bin is the installation path selected during the previous installation.

export PATH="/opt/anaconda3/bin:$PATH"
Copy the code

(3) :wq, save and exit.

(4) Load environment variables

source $HOME/.bash_profile
source ~/.bash_profile
Copy the code

(5) After the operation, enter again to display the version of Conda.

conda --version
Copy the code

In addition, if you enter the conda command every time you restart the terminal, conda command not found is still displayed. You need to enter source ~/. Bash_profile again to access base and use conda. After a search, it was found that anaconda was not configured into the system environment variable.

(1) Enter the command line in terminal, where the part before Anaconda is the previous installation path, which can be found in the introduction displayed in anaconda Navigator.

echo 'export PATH="/opt/anaconda3/bin:$PATH"' >> ~/.zshrc``
Copy the code

(2) Load the environment variable and enter

source ~/.zshrc
Copy the code

(3) Restart the terminal and enter the conda command. It is found that conda can be used successfully.

Mac M1 quick example

Making project: Miniforge


Quick example Open the terminal

wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
bash Miniforge3-MacOSX-arm64.sh
Copy the code

You can customize the directory as prompted



Installation successful:



A simple test

Terminal type: Python automatically jumps into conda’s environment

0x01. Configure tsinghua source

Provides an image of the Anaconda repository with third-party sources (Conda-Forge, MSYS2, PyTorch, etc., see the full list). Each system can modify the.condarc file in the user directory.

Windows

You can edit the configuration file directly. In Windows, the file path is usually C:\Users\ username \.condarc.

Windows users cannot create a. Condarc file. You can run commands on the Anaconda cli to generate the file and then modify it.

conda config --set show_channel_urls yes
Copy the code

Confirm that the content of the file is:

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
Copy the code

You can add Anaconda Python’s free domestic repository.

Run the clear index cache to ensure that the index provided by the mirror is used.

conda clean -i
Copy the code

Mac

Editing a Configuration File

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
Copy the code

Verifying the Configuration

Enter a value on the Anaconda cli

conda config --show
Copy the code

If the following information is displayed, the change is successful.

(base) PS C:\Users\binary> conda config --show
add_anaconda_token: True
add_pip_as_python_dependency: True
aggressive_update_packages:
  - ca-certificates
  - certifi
  - openssl
allow_conda_downgrades: False
allow_cycles: True
allow_non_channel_urls: False
allow_softlinks: False
always_copy: False
always_softlink: False
always_yes: None
anaconda_upload: None
auto_activate_base: True
auto_stack: 0
auto_update_conda: True
bld_path:
changeps1: True
channel_alias: https://conda.anaconda.org
channel_priority: flexible
channels:
  - defaults
client_ssl_cert: None
client_ssl_cert_key: None
clobber: False
conda_build: {}
create_default_packages: []
croot: C:\Users\binary\anaconda3\conda-bld
custom_channels:
  anaconda/pkgs/main: https://mirrors.tuna.tsinghua.edu.cn
  anaconda/pkgs/r: https://mirrors.tuna.tsinghua.edu.cn
  anaconda/pkgs/msys2: https://mirrors.tuna.tsinghua.edu.cn
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
custom_multichannels:
  defaults:
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
  local: debug: False default_channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 default_python: 3.8 default_threads: None deps_modifier: not_set dev: False disallowed_packages: [] download_only: False dry_run: False enable_private_envs: False env_prompt: ({default_env}) envs_dirs: - C:\Users\binary\anaconda3\envs - C:\Users\binary\.conda\envs - C:\Users\binary\AppData\Local\conda\conda\envs error_upload_url: https://conda.io/conda-post/unexpected-error execute_threads: 1 extra_safety_checks: False force: False force_32bit: False force_reinstall: False force_remove: False ignore_pinned: False json: False local_repodata_ttl: 1 migrated_channel_aliases: [] migrated_custom_channels: {} non_admin_enabled: True notify_outdated_conda: True offline: False override_channels_enabled: True path_conflict: clobber pinned_packages: [] pip_interop_enabled: False pkgs_dirs: - C:\Users\binary\anaconda3\pkgs - C:\Users\binary\.conda\pkgs - C:\Users\binary\AppData\Local\conda\conda\pkgs Proxy_servers: {} quiet: False remote_backoff_factor: 1 remote_connect_timeout_secs: 9.15 remote_max_retries: 3 Remote_read_TIMEout_secs: 60.0 rePODATA_fns: - current_repodata.json - repodata_threads: None report_errors: None restore_free_channel: False rollback_enabled: True root_prefix: C:\Users\binary\anaconda3 safety_checks: warn sat_solver: pycosat separate_format_cache: False shortcuts: True show_channel_urls: True signing_metadata_url_base: None solver_ignore_timestamps: False ssl_verify: True subdir: win-64 subdirs: - win-64 - noarch target_prefix_override: track_features: [] unsatisfiable_hints: True unsatisfiable_hints_check_depth: 2 update_modifier: update_specs use_index_cache: False use_local: False use_only_tar_bz2: False verbosity: 0 verify_threads: 1 whitelist_channels: [] (base) PS C:\Users\binary>Copy the code

Create a PIP folder under C:/user and create a new text file named pip.ini. Type the following code:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
Copy the code

Save and exit.

0x02. Resources

Github: Conda commands not working or showing anything in command line

Tsinghua University open source software mirror site description: Anaconda image use help

Cnblogs: Windows environment Anaconda replacement tsinghua source

CSDN: MacBook M1 installed with Anaconda and PyCharm

Language Sparrow: MiniForge 3