Anaconda 安装部分三方包流程说明。

在使用 Anaconda 过程中,一些常用包安装流程操作是:

1
conda install xxx

但是不可避免会使用一些第三方库,这时候还是按照以上语法会安装失败,这里以安装 jieba 库为例(jieba 库是一个常用的中文分词库)。结果如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(base) huangdaludeMacBook-Air:~ xxhuang$ conda install jieba
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

- jieba

Current channels:

- https://repo.anaconda.com/pkgs/main/osx-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/osx-64
- https://repo.anaconda.com/pkgs/r/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

https://anaconda.org

and use the search bar at the top of the page.

错误提示部分包不能以这种方式下载。类似这种情况可以换一种方式。首先可以先找到对应包的版本信息:anaconda search -t conda jieba,返回结果如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(base) huangdaludeMacBook-Air:~ xxhuang$ anaconda search -t conda jieba
Using Anaconda API: https://api.anaconda.org
Packages:
Name | Version | Package Types | Platforms | Builds
------------------------- | ------ | --------------- | --------------- | ----------
auto/jieba | 0.32 | conda | linux-64, linux-32 | py27_0
: http://github.com/fxsjy
conda-forge/jieba | 0.39 | conda | linux-64, win-32, osx-64, noarch, win-64 | py_1, py36_0, py35_0, py27_0
: Chinese Words Segementation Utilities
conda-forge/jieba3k | 0.35.1 | conda | linux-64, win-32, osx-64, win-64, noarch | py36_1001, py37_1001, py36_1, py_0, py35_1001, py38_1001, py35_1
: Chinese Words Segementation Utilities
creditx/jieba | 0.38 | conda | linux-64 | py35_0, py27_0
hargup/jieba | | conda | linux-64 | py27_0
: Chinese Words Segementation Utilities
iilab/jieba | 0.36.2 | conda | linux-64, osx-64 | py34_0
: Chinese Words Segementation Utilities
iilab/jieba3k | 0.35.1 | conda | linux-64, osx-64 | py34_0
: Chinese Words Segementation Utilities
jiangxiluning/jieba | 0.36.2 | conda | linux-64, osx-64, win-64 | py27_0
: Chinese Words Segementation Utilities
moustik/jieba | 0.38 | conda | linux-64 | py27_0
r/r-jiebard | 0.1 | conda | noarch | r36h6115d3f_0
: jiebaR is a package for Chinese text segmentation, keyword extraction and speech tagging. This package provides the data files required by jiebaR.
r_test/r-jiebard | 0.1 | conda | noarch | r36h6115d3f_0
: jiebaR is a package for Chinese text segmentation, keyword extraction and speech tagging. This package provides the data files required by jiebaR.
syllabs_admin/jieba | 0.39 | conda | linux-64 | py27ha286e51_0
Found 12 packages

Run 'anaconda show <USER/PACKAGE>' to get installation details

选择对应的版本,根据版本,输入以下信息:anaconda show conda-forge/jieba,返回结果如下:

1
2
3
4
5
6
7
8
9
10
11
12
(base) huangdaludeMacBook-Air:~ xxhuang$ anaconda show conda-forge/jieba
Using Anaconda API: https://api.anaconda.org
Name: jieba
Summary: Chinese Words Segementation Utilities
Access: public
Package Types: conda
Versions:
+ 0.38
+ 0.39

To install this package with conda run:
conda install --channel https://conda.anaconda.org/conda-forge jieba

根据返回的信息,执行最后一行信息即可安装。输入 conda install –channel https://conda.anaconda.org/conda-forge jieba

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(base) huangdaludeMacBook-Air:~ xxhuang$ conda install --channel https://conda.anaconda.org/conda-forge jieba
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

environment location: /opt/anaconda3

added / updated specs:
- jieba


The following packages will be downloaded:

package | build
---------------------------|-----------------
ca-certificates-2019.11.28 | hecc5488_0 145 KB conda-forge
certifi-2019.11.28 | py37_0 148 KB conda-forge
conda-4.8.2 | py37_0 3.0 MB conda-forge
jieba-0.39 | py_1 5.6 MB conda-forge
openssl-1.1.1d | h0b31af3_0 1.9 MB conda-forge
------------------------------------------------------------
Total: 10.8 MB

The following NEW packages will be INSTALLED:

jieba conda-forge/noarch::jieba-0.39-py_1

The following packages will be UPDATED:

ca-certificates pkgs/main::ca-certificates-2019.11.27~ --> conda-forge::ca-certificates-2019.11.28-hecc5488_0
conda pkgs/main::conda-4.8.1-py37_0 --> conda-forge::conda-4.8.2-py37_0

The following packages will be SUPERSEDED by a higher-priority channel:

certifi pkgs/main --> conda-forge
openssl pkgs/main::openssl-1.1.1d-h1de35cc_3 --> conda-forge::openssl-1.1.1d-h0b31af3_0


Proceed ([y]/n)? y


Downloading and Extracting Packages
conda-4.8.2 | 3.0 MB | ############################################################################################################################################################### | 100%
certifi-2019.11.28 | 148 KB | ############################################################################################################################################################### | 100%
jieba-0.39 | 5.6 MB | ############################################################################################################################################################### | 100%
ca-certificates-2019 | 145 KB | ############################################################################################################################################################### | 100%
openssl-1.1.1d | 1.9 MB | ############################################################################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: \ WARNING conda.core.path_actions:verify(963): Unable to create environments file. Path not writable.
environment location: /Users/xxhuang/.conda/environments.txt

done
Executing transaction: done

如图显示,jieba 包安装完成。