conda环境设置
镜像设置
[pythoning@dev ~]$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
代理设置
$HOME/.condarc 文件中
这个文件中可以看到镜像源信息(如果配置了的话),在下面加上proxy就可以设置代理了:
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults
show_channel_urls: true
proxy_servers:
http: http://xxx.xx.com:8080
https: https://xxx.xx.com:8080
ssl_verify: false
更新
[pythoning@dev ~]# conda update conda
Collecting package metadata (current_repodata.json): done
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 4.12.0
latest version: 4.14.0
Please update conda by running
$ conda update -n base -c defaults conda
## Package Plan ##
environment location: /usr/local/miniconda3
added / updated specs:
- conda
The following packages will be downloaded:
package | build
---------------------------|-----------------
_libgcc_mutex-0.1 | main 3 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
_openmp_mutex-5.1 | 1_gnu 21 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
brotlipy-0.7.0 |py38h27cfd23_1003 323 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ca-certificates-2022.07.19 | h06a4308_0 124 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
certifi-2022.6.15 | py38h06a4308_0 153 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cffi-1.15.1 | py38h74dc2b5_0 228 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
charset-normalizer-2.0.4 | pyhd3eb1b0_0 35 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda-4.14.0 | py38h06a4308_0 916 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda-package-handling-1.8.1| py38h7f8727e_0 885 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cryptography-37.0.1 | py38h9ce1e76_0 1.3 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cytoolz-0.11.0 | py38h7b6447c_0 345 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
idna-3.3 | pyhd3eb1b0_0 49 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ld_impl_linux-64-2.38 | h1181459_1 654 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libffi-3.3 | he6710b0_2 50 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libgcc-ng-11.2.0 | h1234567_1 5.3 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libgomp-11.2.0 | h1234567_1 474 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libstdcxx-ng-11.2.0 | h1234567_1 4.7 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ncurses-6.3 | h5eee18b_3 781 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
openssl-1.1.1q | h7f8727e_0 2.5 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pip-22.1.2 | py38h06a4308_0 2.5 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pycosat-0.6.3 | py38h7b6447c_1 82 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pycparser-2.21 | pyhd3eb1b0_0 94 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pyopenssl-22.0.0 | pyhd3eb1b0_0 50 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pysocks-1.7.1 | py38h06a4308_0 31 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
readline-8.1.2 | h7f8727e_1 354 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
requests-2.28.1 | py38h06a4308_0 92 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ruamel_yaml-0.15.100 | py38h27cfd23_0 258 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
setuptools-63.4.1 | py38h06a4308_0 1.1 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
sqlite-3.39.2 | h5082296_0 1.1 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
tk-8.6.12 | h1ccaba5_0 3.0 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
toolz-0.11.2 | pyhd3eb1b0_0 49 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
tqdm-4.64.0 | py38h06a4308_0 126 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
urllib3-1.26.11 | py38h06a4308_0 182 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
wheel-0.37.1 | pyhd3eb1b0_0 33 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
xz-5.2.5 | h7f8727e_1 339 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
yaml-0.2.5 | h7b6447c_0 75 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
zlib-1.2.12 | h7f8727e_2 106 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
------------------------------------------------------------
Total: 28.2 MB
The following NEW packages will be INSTALLED:
cytoolz anaconda/pkgs/main/linux-64::cytoolz-0.11.0-py38h7b6447c_0
toolz anaconda/pkgs/main/noarch::toolz-0.11.2-pyhd3eb1b0_0
The following packages will be REMOVED:
colorama-0.4.4-pyhd3eb1b0_0
conda-content-trust-0.1.1-pyhd3eb1b0_0
six-1.16.0-pyhd3eb1b0_1
The following packages will be UPDATED:
_openmp_mutex pkgs/main::_openmp_mutex-4.5-1_gnu --> anaconda/pkgs/main::_openmp_mutex-5.1-1_gnu
ca-certificates pkgs/main::ca-certificates-2022.3.29-~ --> anaconda/pkgs/main::ca-certificates-2022.07.19-h06a4308_0
certifi pkgs/main::certifi-2021.10.8-py38h06a~ --> anaconda/pkgs/main::certifi-2022.6.15-py38h06a4308_0
cffi pkgs/main::cffi-1.15.0-py38hd667e15_1 --> anaconda/pkgs/main::cffi-1.15.1-py38h74dc2b5_0
conda pkgs/main::conda-4.12.0-py38h06a4308_0 --> anaconda/pkgs/main::conda-4.14.0-py38h06a4308_0
cryptography pkgs/main::cryptography-36.0.0-py38h9~ --> anaconda/pkgs/main::cryptography-37.0.1-py38h9ce1e76_0
ld_impl_linux-64 pkgs/main::ld_impl_linux-64-2.35.1-h7~ --> anaconda/pkgs/main::ld_impl_linux-64-2.38-h1181459_1
libgcc-ng pkgs/main::libgcc-ng-9.3.0-h5101ec6_17 --> anaconda/pkgs/main::libgcc-ng-11.2.0-h1234567_1
libgomp pkgs/main::libgomp-9.3.0-h5101ec6_17 --> anaconda/pkgs/main::libgomp-11.2.0-h1234567_1
libstdcxx-ng pkgs/main::libstdcxx-ng-9.3.0-hd4cf53~ --> anaconda/pkgs/main::libstdcxx-ng-11.2.0-h1234567_1
ncurses pkgs/main::ncurses-6.3-h7f8727e_2 --> anaconda/pkgs/main::ncurses-6.3-h5eee18b_3
openssl pkgs/main::openssl-1.1.1n-h7f8727e_0 --> anaconda/pkgs/main::openssl-1.1.1q-h7f8727e_0
pip pkgs/main::pip-21.2.4-py38h06a4308_0 --> anaconda/pkgs/main::pip-22.1.2-py38h06a4308_0
requests pkgs/main/noarch::requests-2.27.1-pyh~ --> anaconda/pkgs/main/linux-64::requests-2.28.1-py38h06a4308_0
setuptools pkgs/main::setuptools-61.2.0-py38h06a~ --> anaconda/pkgs/main::setuptools-63.4.1-py38h06a4308_0
sqlite pkgs/main::sqlite-3.38.2-hc218d9a_0 --> anaconda/pkgs/main::sqlite-3.39.2-h5082296_0
tk pkgs/main::tk-8.6.11-h1ccaba5_0 --> anaconda/pkgs/main::tk-8.6.12-h1ccaba5_0
tqdm pkgs/main/noarch::tqdm-4.63.0-pyhd3eb~ --> anaconda/pkgs/main/linux-64::tqdm-4.64.0-py38h06a4308_0
urllib3 pkgs/main/noarch::urllib3-1.26.8-pyhd~ --> anaconda/pkgs/main/linux-64::urllib3-1.26.11-py38h06a4308_0
xz pkgs/main::xz-5.2.5-h7b6447c_0 --> anaconda/pkgs/main::xz-5.2.5-h7f8727e_1
zlib pkgs/main::zlib-1.2.12-h7f8727e_1 --> anaconda/pkgs/main::zlib-1.2.12-h7f8727e_2
The following packages will be SUPERSEDED by a higher-priority channel:
_libgcc_mutex pkgs/main --> anaconda/pkgs/main
brotlipy pkgs/main --> anaconda/pkgs/main
charset-normalizer pkgs/main --> anaconda/pkgs/main
conda-package-han~ pkgs/main --> anaconda/pkgs/main
idna pkgs/main --> anaconda/pkgs/main
libffi pkgs/main --> anaconda/pkgs/main
pycosat pkgs/main --> anaconda/pkgs/main
pycparser pkgs/main --> anaconda/pkgs/main
pyopenssl pkgs/main --> anaconda/pkgs/main
pysocks pkgs/main --> anaconda/pkgs/main
readline pkgs/main --> anaconda/pkgs/main
ruamel_yaml pkgs/main --> anaconda/pkgs/main
wheel pkgs/main --> anaconda/pkgs/main
yaml pkgs/main --> anaconda/pkgs/main
Proceed ([y]/n)? y
Downloading and Extracting Packages
cffi-1.15.1 | 228 KB | ###################################################################### | 100%
idna-3.3 | 49 KB | ###################################################################### | 100%
_libgcc_mutex-0.1 | 3 KB | ###################################################################### | 100%
cryptography-37.0.1 | 1.3 MB | ###################################################################### | 100%
requests-2.28.1 | 92 KB | ###################################################################### | 100%
ld_impl_linux-64-2.3 | 654 KB | ###################################################################### | 100%
brotlipy-0.7.0 | 323 KB | ###################################################################### | 100%
libstdcxx-ng-11.2.0 | 4.7 MB | ###################################################################### | 100%
openssl-1.1.1q | 2.5 MB | ###################################################################### | 100%
pysocks-1.7.1 | 31 KB | ###################################################################### | 100%
_openmp_mutex-5.1 | 21 KB | ###################################################################### | 100%
ca-certificates-2022 | 124 KB | ###################################################################### | 100%
yaml-0.2.5 | 75 KB | ###################################################################### | 100%
pycosat-0.6.3 | 82 KB | ###################################################################### | 100%
wheel-0.37.1 | 33 KB | ###################################################################### | 100%
xz-5.2.5 | 339 KB | ###################################################################### | 100%
libffi-3.3 | 50 KB | ###################################################################### | 100%
tk-8.6.12 | 3.0 MB | ###################################################################### | 100%
toolz-0.11.2 | 49 KB | ###################################################################### | 100%
cytoolz-0.11.0 | 345 KB | ###################################################################### | 100%
readline-8.1.2 | 354 KB | ###################################################################### | 100%
conda-4.14.0 | 916 KB | ###################################################################### | 100%
conda-package-handli | 885 KB | ###################################################################### | 100%
libgomp-11.2.0 | 474 KB | ###################################################################### | 100%
charset-normalizer-2 | 35 KB | ###################################################################### | 100%
zlib-1.2.12 | 106 KB | ###################################################################### | 100%
ruamel_yaml-0.15.100 | 258 KB | ###################################################################### | 100%
urllib3-1.26.11 | 182 KB | ###################################################################### | 100%
pyopenssl-22.0.0 | 50 KB | ###################################################################### | 100%
ncurses-6.3 | 781 KB | ###################################################################### | 100%
sqlite-3.39.2 | 1.1 MB | ###################################################################### | 100%
pip-22.1.2 | 2.5 MB | ###################################################################### | 100%
certifi-2022.6.15 | 153 KB | ###################################################################### | 100%
tqdm-4.64.0 | 126 KB | ###################################################################### | 100%
libgcc-ng-11.2.0 | 5.3 MB | ###################################################################### | 100%
pycparser-2.21 | 94 KB | ###################################################################### | 100%
setuptools-63.4.1 | 1.1 MB | ###################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
退出base环境
anaconda 取消每次默认启动base环境
[pythoning@dev ~]$ conda config --set auto_activate_base false
或者执行 conda deactivate
(base) [pythoning@dev ~]$ conda deactivate
[going@dev ~]$
创建虚拟环境
创建python3.8版本的虚拟环境,执行conda create --name python-guide3 python=3.8
[pythoning@dev ~]$ conda create --name python-guide3 python=3.8
conda create --name python-guide3 python=3.8
激活虚拟环境
(base) [pythoning@dev ~]$ conda activate python-guide3
(python-guide3) [pythoning@dev ~]$
导入项目包
选择用pip导入是因为有时候有些包conda镜像中没用,如果不存在特需包也开源用conda install --yes --file requirements.txt
(python-guide3) [pythoning@dev python-guide]$ pip install -r requirements.txt
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
#输出已经安装的所有包的包名和版本信息
pip freeze
#将上述结果输出重定向到requirements.txt文件中保存
pip freeze > requirements.txt
#批量安装requirements.txt中指定的包
pip install -r requirements.txt
CONDA
#批量导出
conda list -e > requirements.txt
#批量安装
conda install --yes --file requirements.txt