环境管理(适用mac)
//检查conda版本或是否已经安装
(base) lzh:~ mac$ conda --version
conda 4.10.1
// 检查依赖包
(base) lzh:~ mac$ conda list
...
// 更新anaconda(一般情况下不用)
(base) lzh:~ mac$ conda update conda
Collecting package metadata (current_repodata.json): done
Solving environment: done
...
//创建一个名称为"validator_sd"的python版本为3.8的虚拟环境
(base) lzh:envs mac$ conda create --name validator_sd python=3.8
Collecting package metadata (current_repodata.json): done
Solving environment: done
...
// 若创建不成功, 先清除缓存的pkg
(base) lzh:envs mac$ conda clean --all
...
可以进入相应的目录下,删除相应文件
再删除anaconda3/envs/目录下你刚刚新建的虚拟环境的目录,再conda create
// macOS和linux下, 切换虚拟环境
(base) lzh:envs mac$ source activate validator_sd
(validator_sd) lzh:envs mac$
// macOS和linux下, 切换虚拟环境方式2
(base) lzh:envs mac$ conda activate validator_sd
(validator_sd) lzh:envs mac$
// macOS和linux下, 退出当前虚拟环境
(validator_sd) lzh:envs mac$ conda deactivate
(base) lzh:envs mac$
// 列出已经创建的虚拟环境
(validator_sd) lzh:envs mac$ conda env list
base /Users/mac/opt/anaconda3
// 复制一个虚拟环境, 从validator_sd复制出一个虚拟环境,名称为validator
(validator_sd) lzh:conda-meta mac$ conda create --name validator --clone validator_sd
Source: /Users/mac/opt/anaconda3/envs/validator_sd
Destination: /Users/mac/opt/anaconda3/envs/validator
Packages: 0
Files: 0
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
// 删除一个名 validator的虚拟环境
(validator_sd) lzh:conda-meta mac$ conda remove --name validator --all
Remove all packages in environment /Users/mac/opt/anaconda3/envs/validator:
No packages found in /Users/mac/opt/anaconda3/envs/validator. Continuing environment removal
1.2 创建虚拟环境失败后,排查问题,并再次成功创建虚拟环境的过程
(base) lzh:envs mac$ conda create --name valicator_sd python=3.8
Collecting package metadata (current_repodata.json): done
Solving environment: done
environment location: /Users/mac/opt/anaconda3/envs/valicator_sd
added / updated specs:
- python=3.8
The following packages will be downloaded:
package | build
---------------------------|-----------------
ca-certificates-2022.3.29 | hecd8cb5_1 122 KB
openssl-1.1.1n | hca72f7f_0 2.2 MB
python-3.8.13 | hdfd78df_0 10.8 MB
setuptools-61.2.0 | py38hecd8cb5_0 1012 KB
sqlite-3.38.2 | h707629a_0 1.2 MB
zlib-1.2.12 | h4dc903c_1 97 KB
------------------------------------------------------------
Total: 15.4 MB
The following NEW packages will be INSTALLED:
ca-certificates pkgs/main/osx-64::ca-certificates-2022.3.29-hecd8cb5_1
certifi pkgs/main/osx-64::certifi-2021.10.8-py38hecd8cb5_2
libcxx pkgs/main/osx-64::libcxx-12.0.0-h2f01273_0
libffi pkgs/main/osx-64::libffi-3.3-hb1e8313_2
ncurses pkgs/main/osx-64::ncurses-6.3-hca72f7f_2
openssl pkgs/main/osx-64::openssl-1.1.1n-hca72f7f_0
pip pkgs/main/osx-64::pip-21.2.4-py38hecd8cb5_0
python pkgs/main/osx-64::python-3.8.13-hdfd78df_0
readline pkgs/main/osx-64::readline-8.1.2-hca72f7f_1
setuptools pkgs/main/osx-64::setuptools-61.2.0-py38hecd8cb5_0
sqlite pkgs/main/osx-64::sqlite-3.38.2-h707629a_0
tk pkgs/main/osx-64::tk-8.6.11-h7bc2e8c_0
wheel pkgs/main/noarch::wheel-0.37.1-pyhd3eb1b0_0
xz pkgs/main/osx-64::xz-5.2.5-h1de35cc_0
zlib pkgs/main/osx-64::zlib-1.2.12-h4dc903c_1
Proceed ([y]/n)? y
Downloading and Extracting Packages
sqlite-3.38.2 | 1.2 MB |
ca-certificates-2022 | 122 KB |
openssl-1.1.1n | 2.2 MB |
zlib-1.2.12 | 97 KB |
setuptools-61.2.0 | 1012 KB |
python-3.8.13 | 10.8 MB |
Preparing transaction: done
Verifying transaction: failed
CondaVerificationError: The package for ncurses located at /Users/mac/opt/anaconda3/pkgs/ncurses-6.3-hca72f7f_2 **//错误点**
appears to be corrupted. The path 'share/terminfo/69/iterm2'
specified in the package manifest cannot be found.
(base) lzh:envs mac$ pwd
/Users/mac/opt/anaconda3/envs
(base) lzh:envs mac$ cd ..
(base) lzh:anaconda3 mac$ cd pkgs/
(base) lzh:pkgs mac$ rm -rf ncurses-6.3-hca72f7f_2/
(base) lzh:pkgs mac$ pwd
/Users/mac/opt/anaconda3/pkgs
(base) lzh:pkgs mac$ cd ..
(base) lzh:anaconda3 mac$ cd envs/
(base) lzh:envs mac$ ll
total 0
drwxr-xr-x 24 mac staff 768 Apr 21 13:49 apidev38
drwxr-xr-x 9 mac staff 288 Jun 21 2021 etl38
drwxr-xr-x 9 mac staff 288 Jun 21 2021 nlp38
drwxr-xr-x 49 mac staff 1568 Mar 15 11:49 sse38
drwxr-xr-x 3 mac staff 96 Apr 21 15:24 valicator_sd
(base) lzh:envs mac$ conda remove --name validator_sd --all
(base) lzh:envs mac$ ll
total 0
drwxr-xr-x 24 mac staff 768 Apr 21 13:49 apidev38
drwxr-xr-x 9 mac staff 288 Jun 21 2021 etl38
drwxr-xr-x 9 mac staff 288 Jun 21 2021 nlp38
drwxr-xr-x 49 mac staff 1568 Mar 15 11:49 sse38
drwxr-xr-x 3 mac staff 96 Apr 21 15:24 valicator_sd
(base) lzh:envs mac$ rm -rf valicator_sd/
(base) lzh:envs mac$ ll
total 0
drwxr-xr-x 24 mac staff 768 Apr 21 13:49 apidev38
drwxr-xr-x 9 mac staff 288 Jun 21 2021 etl38
drwxr-xr-x 9 mac staff 288 Jun 21 2021 nlp38
drwxr-xr-x 49 mac staff 1568 Mar 15 11:49 sse38
(base) lzh:envs mac$ conda clean --all
Cache location: /Users/mac/opt/anaconda3/pkgs
Will remove the following tarballs:
/Users/mac/opt/anaconda3/pkgs
-----------------------------
openssl-1.1.1n-hca72f7f_0.conda 2.2 MB
ca-certificates-2022.3.29-hecd8cb5_1.conda 122 KB
zlib-1.2.12-h4dc903c_1.conda 97 KB
setuptools-61.2.0-py38hecd8cb5_0.conda 1012 KB
sqlite-3.38.2-h707629a_0.conda 1.2 MB
python-3.8.13-hdfd78df_0.conda 10.8 MB
---------------------------------------------------
Total: 15.4 MB
Proceed ([y]/n)? y
Removed openssl-1.1.1n-hca72f7f_0.conda
Removed ca-certificates-2022.3.29-hecd8cb5_1.conda
Removed zlib-1.2.12-h4dc903c_1.conda
Removed setuptools-61.2.0-py38hecd8cb5_0.conda
Removed sqlite-3.38.2-h707629a_0.conda
Removed python-3.8.13-hdfd78df_0.conda
WARNING: /Users/mac/.conda/pkgs does not exist
Cache location: /Users/mac/opt/anaconda3/pkgs
Will remove the following packages:
/Users/mac/opt/anaconda3/pkgs
-----------------------------
zlib-1.2.12-h4dc903c_1 468 KB
sqlite-3.38.2-h707629a_0 4.2 MB
python-3.8.13-hdfd78df_0 40.4 MB
setuptools-61.2.0-py38hecd8cb5_0 5.8 MB
openssl-1.1.1n-hca72f7f_0 9.9 MB
ca-certificates-2022.3.29-hecd8cb5_1 232 KB
---------------------------------------------------
Total: 61.0 MB
Proceed ([y]/n)? y
removing zlib-1.2.12-h4dc903c_1
removing sqlite-3.38.2-h707629a_0
removing python-3.8.13-hdfd78df_0
removing setuptools-61.2.0-py38hecd8cb5_0
removing openssl-1.1.1n-hca72f7f_0
removing ca-certificates-2022.3.29-hecd8cb5_1
(base) lzh:envs mac$ ll
total 0
drwxr-xr-x 24 mac staff 768 Apr 21 13:49 apidev38
drwxr-xr-x 9 mac staff 288 Jun 21 2021 etl38
drwxr-xr-x 9 mac staff 288 Jun 21 2021 nlp38
drwxr-xr-x 49 mac staff 1568 Mar 15 11:49 sse38
(base) lzh:envs mac$ conda create --name validator_sd python=3.8
Collecting package metadata (current_repodata.json): done
Solving environment: done
environment location: /Users/mac/opt/anaconda3/envs/validator_sd
added / updated specs:
- python=3.8
The following packages will be downloaded:
package | build
---------------------------|-----------------
ca-certificates-2022.3.29 | hecd8cb5_1 122 KB
ncurses-6.3 | hca72f7f_2 856 KB
openssl-1.1.1n | hca72f7f_0 2.2 MB
python-3.8.13 | hdfd78df_0 10.8 MB
setuptools-61.2.0 | py38hecd8cb5_0 1012 KB
sqlite-3.38.2 | h707629a_0 1.2 MB
zlib-1.2.12 | h4dc903c_1 97 KB
------------------------------------------------------------
Total: 16.2 MB
The following NEW packages will be INSTALLED:
ca-certificates pkgs/main/osx-64::ca-certificates-2022.3.29-hecd8cb5_1
certifi pkgs/main/osx-64::certifi-2021.10.8-py38hecd8cb5_2
libcxx pkgs/main/osx-64::libcxx-12.0.0-h2f01273_0
libffi pkgs/main/osx-64::libffi-3.3-hb1e8313_2
ncurses pkgs/main/osx-64::ncurses-6.3-hca72f7f_2
openssl pkgs/main/osx-64::openssl-1.1.1n-hca72f7f_0
pip pkgs/main/osx-64::pip-21.2.4-py38hecd8cb5_0
python pkgs/main/osx-64::python-3.8.13-hdfd78df_0
readline pkgs/main/osx-64::readline-8.1.2-hca72f7f_1
setuptools pkgs/main/osx-64::setuptools-61.2.0-py38hecd8cb5_0
sqlite pkgs/main/osx-64::sqlite-3.38.2-h707629a_0
tk pkgs/main/osx-64::tk-8.6.11-h7bc2e8c_0
wheel pkgs/main/noarch::wheel-0.37.1-pyhd3eb1b0_0
xz pkgs/main/osx-64::xz-5.2.5-h1de35cc_0
zlib pkgs/main/osx-64::zlib-1.2.12-h4dc903c_1
Proceed ([y]/n)? y
Downloading and Extracting Packages
openssl-1.1.1n | 2.2 MB |
ca-certificates-2022 | 122 KB |
python-3.8.13 | 10.8 MB |
setuptools-61.2.0 | 1012 KB |
ncurses-6.3 | 856 KB |
sqlite-3.38.2 | 1.2 MB |
zlib-1.2.12 | 97 KB |
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(base) lzh:envs mac$
依赖包管理
(base) lzh:envs mac$ conda install --name validator_sd pandas
Collecting package metadata (current_repodata.json): done
Solving environment: done
environment location: /Users/mac/opt/anaconda3/envs/validator_sd
added / updated specs:
- pandas
The following packages will be downloaded:
package | build
---------------------------|-----------------
blas-1.0 | mkl 6 KB
bottleneck-1.3.4 | py38h67323c0_0 115 KB
intel-openmp-2021.4.0 | hecd8cb5_3538 961 KB
mkl-2021.4.0 | hecd8cb5_637 101.0 MB
mkl-service-2.4.0 | py38h9ed2024_0 45 KB
mkl_fft-1.3.1 | py38h4ab4a9b_0 165 KB
mkl_random-1.2.2 | py38hb2f4e1b_0 273 KB
numexpr-2.8.1 | py38h2e5f0a9_0 122 KB
numpy-1.21.5 | py38h2e5f0a9_1 24 KB
numpy-base-1.21.5 | py38h3b1a694_1 4.7 MB
packaging-21.3 | pyhd3eb1b0_0 36 KB
pandas-1.4.1 | py38he9d5cce_1 9.3 MB
pyparsing-3.0.4 | pyhd3eb1b0_0 81 KB
python-dateutil-2.8.2 | pyhd3eb1b0_0 233 KB
pytz-2021.3 | pyhd3eb1b0_0 171 KB
six-1.16.0 | pyhd3eb1b0_1 18 KB
------------------------------------------------------------
Total: 117.2 MB
The following NEW packages will be INSTALLED:
blas pkgs/main/osx-64::blas-1.0-mkl
bottleneck pkgs/main/osx-64::bottleneck-1.3.4-py38h67323c0_0
intel-openmp pkgs/main/osx-64::intel-openmp-2021.4.0-hecd8cb5_3538
mkl pkgs/main/osx-64::mkl-2021.4.0-hecd8cb5_637
mkl-service pkgs/main/osx-64::mkl-service-2.4.0-py38h9ed2024_0
mkl_fft pkgs/main/osx-64::mkl_fft-1.3.1-py38h4ab4a9b_0
mkl_random pkgs/main/osx-64::mkl_random-1.2.2-py38hb2f4e1b_0
numexpr pkgs/main/osx-64::numexpr-2.8.1-py38h2e5f0a9_0
numpy pkgs/main/osx-64::numpy-1.21.5-py38h2e5f0a9_1
numpy-base pkgs/main/osx-64::numpy-base-1.21.5-py38h3b1a694_1
packaging pkgs/main/noarch::packaging-21.3-pyhd3eb1b0_0
pandas pkgs/main/osx-64::pandas-1.4.1-py38he9d5cce_1
pyparsing pkgs/main/noarch::pyparsing-3.0.4-pyhd3eb1b0_0
python-dateutil pkgs/main/noarch::python-dateutil-2.8.2-pyhd3eb1b0_0
pytz pkgs/main/noarch::pytz-2021.3-pyhd3eb1b0_0
six pkgs/main/noarch::six-1.16.0-pyhd3eb1b0_1
Proceed ([y]/n)? y
....
(base) lzh:envs mac$ conda activate validator_sd
(validator_sd) lzh:envs mac$ conda install pandas
(validator_sd) lzh:envs mac$ pip install pandas
(base) lzh:envs mac$ conda remove --name validator_sd pandas
(base) lzh:envs mac$ conda activate validator_sd
(validator_sd) lzh:envs mac$ pip uninstall pandas
(validator_sd) lzh:envs mac$ conda remove pandas
(base) lzh:envs mac$ conda upgrade --all // 更新所有包
(base) lzh:envs mac$ conda upgrade pandas // 更新指定包
|