1
|
conda create -n dagan python=3.5
|
1
|
conda config --set auto_activate_base false
|
1
|
conda config --set auto_activate_base true
|
1
|
conda remove -n [dagan] --all
|
生成 .condarc
文件:
1
|
conda config --set show_channel_urls yes
|
替换文件内容为:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
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
pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
|
直接先把之前的镜像源清一清
1
|
conda config --remove-key channels
|
再设置镜像源
1
2
3
|
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
|
查看是否替换成功:
使用 python -m site
命令查看当前默认路径
1
2
3
4
5
6
7
8
9
10
11
12
|
(math) ghost7@Ghosts-MacBook-Pro ~ % python -m site
sys.path = [
'/Users/ghost7',
'/Users/ghost7/miniforge3/envs/math/lib/python38.zip',
'/Users/ghost7/miniforge3/envs/math/lib/python3.8',
'/Users/ghost7/miniforge3/envs/math/lib/python3.8/lib-dynload',
'/Users/ghost7/.local/lib/python3.8/site-packages',
'/Users/ghost7/miniforge3/envs/math/lib/python3.8/site-packages',
]
USER_BASE: '/Users/ghost7/.local' (exists)
USER_SITE: '/Users/ghost7/.local/lib/python3.8/site-packages' (exists)
ENABLE_USER_SITE: True
|
发现调用的是 .local
的路径
更改为虚拟环境中的路径
修改 site.py
文件,文件位置在 /Users/ghost7/miniforge3/envs/math/lib/python3.8/site.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
......
# Prefixes for site-packages; add additional prefixes like /usr/local here
PREFIXES = [sys.prefix, sys.exec_prefix]
# Enable per user site-packages directory
# set it to False to disable the feature or True to force the feature
ENABLE_USER_SITE = None
# for distutils.commands.install
# These values are initialized by the getuserbase() and getusersitepackages()
# functions, through the main() function when Python starts.
USER_SITE = None
USER_BASE = None
......
|
默认 USER_SITE 和 USER_BASE 均为 None
修改为自定义的路径
USER_SITE = '/Users/ghost7/miniforge3/envs/math/lib/python3.8/site-packages'
USER_BASE = '/Users/ghost7/miniforge3/envs/math/bin'
1
2
3
4
|
# Use this first command to see what rc files will be updated
conda init --reverse --dry-run
# Use this next command to take action on the rc files listed above
conda init --reverse
|
1
2
3
4
5
6
|
CONDA_BASE_ENVIRONMENT=$(conda info --base)
echo The next command will delete all files in ${CONDA_BASE_ENVIRONMENT}
# Warning, the rm command below is irreversible!
# check the output of the echo command above
# To make sure you are deleting the correct directory
rm -rf ${CONDA_BASE_ENVIRONMENT}
|
1
2
|
echo ${HOME}/.condarc will be removed if it exists
rm -f "${HOME}/.condarc"
|
官网:https://www.anaconda.com/
下载名为 64-Bit (M1) Graphical Installer (316 MB)
的安装包
安装即可
下载安装包
1
|
wget https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh
|
运行安装脚本
1
|
sudo sh ./Anaconda3-2022.05-Linux-x86_64.sh
|
按照提示安装即可