anaconda 环境

这篇文章主要记录如何在mac上安装anaconda和opencv.

安装anaconda很简单,从官网下载后一直点击下一步就行。

默认安装完的anaconda是没有opencv的,而python3.6和opencv3.3又是我期望的版本,所以下面的记录是安装这两个的步骤。
首先注意几个问题:
1.我使用了zsh,所以虽然安装完anaconda之后,它会修改~/.bash_profile的内容,自动添加自己的路径到PATH中,但是由于安装了zsh,所以zsh的终端会读取~/.zshrc,就是说需要手动再把~/.bash_profile中的PATH内容加到~/.zshrc中。当然了,如果你没有使用zsh,而是系统自带的终端,那就不必这样操作了,因为你的系统里根本就不会有~/.zshrc这个文件。

?

1

2

# added by Anaconda3 5.0.0 installer

export PATH="/Users/zz/anaconda3/bin:$PATH"

就是上面的代码,添加到~/.zshrc的末尾就行了。

接下来,重新登录一下系统,或是source ~/.zshrc,然后看看能不能从识别到添加的路径。

?

1

2

3

4

5

? ~/ which conda

/Users/zz/anaconda3/bin/conda

? ~/ conda --version

conda 4.3.28

? ~/

看到上面的结果,就表示安装anaconda成功了。

接下来看看有没有opencv:

?

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

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

? ~/ conda list

# packages in environment at /Users/zz/anaconda3:

#

_ipyw_jlab_nb_ext_conf    0.1.0            py36h2fc01ae_0

alabaster                 0.7.10           py36h174008c_0

anaconda                  5.0.0            py36hd9bc8a5_0

anaconda-client           1.6.5            py36h04cfe59_0

anaconda-navigator        1.6.8            py36hee14809_1

anaconda-project          0.8.0            py36h99320b2_0

appnope                   0.1.0            py36hf537a9a_0

appscript                 1.0.1            py36h9e71e49_1

asn1crypto                0.22.0           py36hb705621_1

astroid                   1.5.3            py36h1333018_0

astropy                   2.0.2            py36hf79c81d_4

babel                     2.5.0            py36h9f161ff_0

backports                 1.0              py36ha3c1827_1

backports.shutil_get_terminal_size 1.0.0            py36hd7a2ee4_2

beautifulsoup4            4.6.0            py36h72d3c9f_1

bitarray                  0.8.1            py36h20fa61d_0

bkcharts                  0.2              py36h073222e_0

blaze                     0.11.3           py36h02e7a37_0

bleach                    2.0.0            py36h8fcea71_0

bokeh                     0.12.7           py36hf2e3fb6_1

boto                      2.48.0           py36hdbc59ac_1

bottleneck                1.2.1            py36hbd380ad_0

ca-certificates           2017.08.26           ha1e5d58_0

certifi                   2017.7.27.1      py36hd973bb6_0

cffi                      1.10.0           py36h880867e_1

chardet                   3.0.4            py36h96c241c_1

click                     6.7              py36hec950be_0

cloudpickle               0.4.0            py36h13b7e56_0

clyent                    1.2.2            py36hae3ad88_0

colorama                  0.3.9            py36hd29a30c_0

conda                     4.3.28           py36h3b51d6a_0

conda-build               3.0.22           py36hcb85c65_0

conda-env                 2.6.0                h36134e3_0

conda-verify              2.0.0            py36he837df3_0

contextlib2               0.5.5            py36hd66e5e7_0

cryptography              2.0.3            py36h22d4226_1

curl                      7.55.1               h7601780_3

cycler                    0.10.0           py36hfc81398_0

cython                    0.26.1           py36hd51f8eb_0

cytoolz                   0.8.2            py36h290905f_0

dask                      0.15.2           py36h4a50f7f_0

dask-core                 0.15.2           py36h151e743_0

datashape                 0.5.4            py36hfb22df8_0

dbus                      1.10.22              h50d9ad6_0

decorator                 4.1.2            py36h69a1b52_0

distributed               1.18.3           py36h46ea802_0

docutils                  0.14             py36hbfde631_0

entrypoints               0.2.3            py36hd81d71f_2

et_xmlfile                1.0.1            py36h1315bdc_0

expat                     2.2.4                h8f26bf8_1

fastcache                 1.0.2            py36h8606a76_0

filelock                  2.0.12           py36h0d0b4fb_0

flask                     0.12.2           py36h5658096_0

flask-cors                3.0.3            py36h7387b97_0

freetype                  2.8                  h143eb01_0

get_terminal_size         1.0.0                h7520d66_0

gettext                   0.19.8.1             hb0f4f8b_2

gevent                    1.2.2            py36ha70b9d6_0

glib                      2.53.6               ha08cb78_1

glob2                     0.5              py36h12393a9_0

gmp                       6.1.2                h4a9834d_0

gmpy2                     2.0.8            py36h7ef02cb_1

greenlet                  0.4.12           py36hf09ba7b_0

h5py                      2.7.0            py36h6400cee_1

hdf5                      1.10.1               h6090a45_0

heapdict                  1.0.0            py36h27a9ac6_0

html5lib                  0.999999999      py36h79312fd_0

icu                       58.2                 hea21ae5_0

idna                      2.6              py36h8628d0a_1

imageio                   2.2.0            py36h5e01289_0

imagesize                 0.7.1            py36h3495948_0

intel-openmp              2018.0.0             hdd0ccc9_7

ipykernel                 4.6.1            py36h3208c25_0

ipython                   6.1.0            py36hf612aae_1

ipython_genutils          0.2.0            py36h241746c_0

ipywidgets                7.0.0            py36h24d3910_0

isort                     4.2.15           py36hceb2a01_0

itsdangerous              0.24             py36h49fbb8d_1

jbig                      2.1                  h4d881f8_0

jdcal                     1.3              py36h1986823_0

jedi                      0.10.2           py36h6325097_0

jinja2                    2.9.6            py36hde4beb4_1

jpeg                      9b                   haccd157_1

jsonschema                2.6.0            py36hb385e00_0

jupyter                   1.0.0            py36h598a6cc_0

jupyter_client            5.1.0            py36hf6c435f_0

jupyter_console           5.2.0            py36hccf5b1c_1

jupyter_core              4.3.0            py36h93810fe_0

jupyterlab                0.27.0           py36hd3092eb_2

jupyterlab_launcher       0.4.0            py36h93e02e9_0

lazy-object-proxy         1.3.1            py36h2fbbe47_0

libcxx                    4.0.1                h579ed51_0

libcxxabi                 4.0.1                hebd6815_0

libedit                   3.1                  hb4e282d_0

libffi                    3.2.1                hd939716_3

libgfortran               3.0.1                h93005f0_2

libiconv                  1.15                 h99df5da_5

libpng                    1.6.32               hce72d48_2

libsodium                 1.0.13               hba5e272_2

libssh2                   1.8.0                h1218725_2

libtiff                   4.0.8                h8cd0352_9

libxml2                   2.9.4                hbd0960b_5

libxslt                   1.1.29               h95a2935_5

llvmlite                  0.20.0                   py36_0

locket                    0.2.0            py36hca03003_1

lxml                      3.8.0            py36h1003d81_0

markupsafe                1.0              py36h3a1e703_1

matplotlib                2.0.2            py36h507e440_1

mccabe                    0.6.1            py36hdaeb55d_0

mistune                   0.7.4            py36hccd6237_0

mkl                       2018.0.0             hc285769_4

mkl-service               1.1.2            py36h7ea6df4_4

mpc                       1.0.3                hc455b36_4

mpfr                      3.1.5                h7fa3772_1

mpmath                    0.19             py36h9185fea_2

msgpack-python            0.4.8            py36h46767b2_0

multipledispatch          0.4.9            py36hc5f92b5_0

navigator-updater         0.1.0            py36h7aee5fb_0

nbconvert                 5.3.1            py36h810822e_0

nbformat                  4.4.0            py36h827af21_0

ncurses                   6.0                  ha932d30_1

networkx                  1.11             py36he1dbd48_0

nltk                      3.2.4            py36h27d1ea0_0

nose                      1.3.7            py36h73fae2b_2

notebook                  5.0.0            py36h462289e_2

numba                     0.35.0              np113py36_6

numexpr                   2.6.2            py36h0f4f1da_1

numpy                     1.13.1           py36h93d791d_2

numpydoc                  0.7.0            py36he54d08e_0

odo                       0.5.1            py36hc1af34a_0

olefile                   0.44             py36ha08bf50_0

openpyxl                  2.4.8            py36he899640_1

openssl                   1.0.2l               h57f3a61_2

packaging                 16.8             py36he5e8135_0

pandas                    0.20.3           py36hd6655d8_2

pandoc                    1.19.2.1             ha5e8f32_1

pandocfilters             1.4.2            py36h3b0b094_1

partd                     0.3.8            py36hf5c4cb8_0

path.py                   10.3.1           py36hd33c240_0

pathlib2                  2.3.0            py36h877a6d8_0

patsy                     0.4.1            py36ha1b3fa5_0

pcre                      8.41                 h29eefc5_0

pep8                      1.7.0            py36hc268eb1_0

pexpect                   4.2.1            py36h3eac828_0

pickleshare               0.7.4            py36hf512f8e_0

pillow                    4.2.1            py36h0263179_0

pip                       9.0.1            py36hbbb9e21_2

pkginfo                   1.4.1            py36h25bf955_0

ply                       3.10             py36h10e714e_0

prompt_toolkit            1.0.15           py36haeda067_0

psutil                    5.2.2            py36hce78e15_0

ptyprocess                0.5.2            py36he6521c3_0

py                        1.4.34           py36hecf431b_1

pycodestyle               2.3.1            py36h83e8646_0

pycosat                   0.6.2            py36h1486600_0

pycparser                 2.18             py36h724b2fc_1

pycrypto                  2.6.1            py36h72f2894_1

pycurl                    7.43.0           py36hdb90038_3

pyflakes                  1.5.0            py36h7fdd505_1

pygments                  2.2.0            py36h240cd3f_0

pylint                    1.7.2            py36h2492be7_0

pyodbc                    4.0.17           py36h5478161_0

pyopenssl                 17.2.0           py36h5d7bf08_0

pyparsing                 2.2.0            py36hb281f35_0

pyqt                      5.6.0            py36he5c6137_6

pysocks                   1.6.7            py36hfa33cec_1

pytables                  3.4.2            py36h6e7b07d_1

pytest                    3.2.1            py36h9963153_1

python                    3.6.2               h26d10c0_12

python-dateutil           2.6.1            py36h86d2abb_1

python.app                2                py36h02ac5de_5

pytz                      2017.2           py36h2e7dfbc_1

pywavelets                0.5.2            py36h2710a04_0

pyyaml                    3.12             py36h2ba1e63_1

pyzmq                     16.0.2           py36h087ffad_2

qt                        5.6.2               h9975529_14

qtawesome                 0.4.4            py36h468c6fb_0

qtconsole                 4.3.1            py36hd96c0ff_0

qtpy                      1.3.1            py36h16bb863_0

readline                  7.0                  h81b24a6_3

requests                  2.18.4           py36h4516966_1

rope                      0.10.5           py36h5764ad1_0

ruamel_yaml               0.11.14          py36h9d7ade0_2

scikit-image              0.13.0           py36h398857d_1

scikit-learn              0.19.0           py36h4cafacf_2

scipy                     0.19.1           py36h3e758e1_3

seaborn                   0.8.0            py36h74df97e_0

setuptools                36.5.0           py36h2134326_0

simplegeneric             0.8.1            py36he5b5b09_0

singledispatch            3.4.0.3          py36hf20db9d_0

sip                       4.18.1           py36h2824476_2

six                       1.10.0           py36h1d5bd22_1

snowballstemmer           1.2.1            py36h6c7b616_0

sortedcollections         0.5.3            py36he9c3ed6_0

sortedcontainers          1.5.7            py36ha982688_0

sphinx                    1.6.3            py36hcd1b3e7_0

sphinxcontrib             1.0              py36h9364dc8_1

sphinxcontrib-websupport  1.0.1            py36h92f4a7a_1

spyder                    3.2.3            py36hfd52dc3_0

sqlalchemy                1.1.13           py36h156b851_0

sqlite                    3.20.1               h900c3b0_1

statsmodels               0.8.0            py36h9c68fc9_0

sympy                     1.1.1            py36h7f3cf04_0

tblib                     1.3.2            py36hda67792_0

terminado                 0.6              py36h656782e_0

testpath                  0.3.1            py36h625a49b_0

tk                        8.6.7                hcdce994_1

toolz                     0.8.2            py36h7b95164_0

tornado                   4.5.2            py36h468dda9_0

traitlets                 4.3.2            py36h65bd3ce_0

typing                    3.6.2            py36haa2d9ef_0

unicodecsv                0.14.1           py36he531d66_0

unixodbc                  2.3.4                h4cb4dde_1

urllib3                   1.22             py36h68b9469_0

wcwidth                   0.1.7            py36h8c6ec74_0

webencodings              0.5.1            py36h3b9701d_1

werkzeug                  0.12.2           py36h168efa1_0

wheel                     0.29.0           py36h3597b6d_1

widgetsnbextension        3.0.2            py36h91f43ea_1

wrapt                     1.10.11          py36hc29e774_0

xlrd                      1.1.0            py36h336f4a2_1

xlsxwriter                0.9.8            py36h3a83402_0

xlwings                   0.11.4           py36hc75f156_0

xlwt                      1.2.0            py36h5ad1178_0

xz                        5.2.3                ha24016e_1

yaml                      0.1.7                hff548bb_1

zeromq                    4.2.2                h131e0f7_1

zict                      0.1.2            py36h117f4c7_0

zlib                      1.2.11               h60db283_1

其实应该是没有opencv的,否则的话就不会有下面的内容了。
之所以列出了上面的那一堆已经安装了库,主要是想记录一下conda list 这个命令的作用。

既然没有,那接下来就是安装过程了。
期初,我按照网上的操作,结果出现了类似下面的情况,为什么说类似呢,是因为我当时没有记录下来自己的错误提示,这里引用了别人的,但结果是99%类似的。

?

1

2

3

4

5

6

7

$ conda install -c menpo opencv3

Fetching package metadata ...........

Solving package specifications: .

UnsatisfiableError: The following specifications were found to be in conflict:

  - opencv3 -> python 2.7* -> openssl 1.0.1*

  - python 3.6*

Use "conda info <package>" to see the dependencies for each package.</package>

当时不太理解,现在明白了,这个提示的意思是说:在当前的环境下,也就是那个console的环境下,要安装Opencv3,但是那个环境下python是2.7的,不是opencv3依赖的3.6,也就是版本不对应。哦对了,那个-c是什么意思呢?它后面跟的是一个安装源url,这里的menpo指的是一个安装源。后面会有解释。

怎么办呢?

把当前的环境改一下,使用python3.6,以便安装opencv3.

?

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

55

56

57

58

59

60

61

? ~/ conda create -n zopencv python=3.6.2

Fetching package metadata .............

Solving package specifications: .

 

Package plan for installation in environment /Users/zz/anaconda3/envs/zopencv:

 

The following NEW packages will be INSTALLED:

 

    ca-certificates: 2017.08.26-ha1e5d58_0

    certifi:         2017.7.27.1-py36hd973bb6_0

    libcxx:          4.0.1-h579ed51_0

    libcxxabi:       4.0.1-hebd6815_0

    libedit:         3.1-hb4e282d_0

    libffi:          3.2.1-hd939716_3

    ncurses:         6.0-ha932d30_1

    openssl:         1.0.2l-h57f3a61_2

    pip:             9.0.1-py36hbd95645_3

    python:          3.6.2-hd04bb42_19

    readline:        7.0-h81b24a6_3

    setuptools:      36.5.0-py36h2134326_0

    sqlite:          3.20.1-h900c3b0_1

    tk:              8.6.7-hcdce994_1

    wheel:           0.29.0-py36h3597b6d_1

    xz:              5.2.3-ha24016e_1

    zlib:            1.2.11-h60db283_1

 

Proceed ([y]/n)? y

 

ca-certificate 100% |########################################################################################| Time: 0:00:01 179.86 kB/s

libcxxabi-4.0. 100% |########################################################################################| Time: 0:00:00 257.24 kB/s

tk-8.6.7-hcdce 100% |########################################################################################| Time: 0:00:10 317.57 kB/s

xz-5.2.3-ha240 100% |########################################################################################| Time: 0:00:00 604.70 kB/s

zlib-1.2.11-h6 100% |########################################################################################| Time: 0:00:00 684.85 kB/s

libcxx-4.0.1-h 100% |########################################################################################| Time: 0:00:01 583.14 kB/s

openssl-1.0.2l 100% |########################################################################################| Time: 0:00:05 683.18 kB/s

libffi-3.2.1-h 100% |########################################################################################| Time: 0:00:00   2.56 MB/s

ncurses-6.0-ha 100% |########################################################################################| Time: 0:00:00   1.12 MB/s

libedit-3.1-hb 100% |########################################################################################| Time: 0:00:00   1.58 MB/s

readline-7.0-h 100% |########################################################################################| Time: 0:00:00   1.01 MB/s

sqlite-3.20.1- 100% |########################################################################################| Time: 0:00:01   1.17 MB/s

python-3.6.2-h 100% |########################################################################################| Time: 0:00:20 655.64 kB/s

certifi-2017.7 100% |########################################################################################| Time: 0:00:00 335.91 kB/s

setuptools-36. 100% |########################################################################################| Time: 0:00:02 237.97 kB/s

wheel-0.29.0-p 100% |########################################################################################| Time: 0:00:00 448.89 kB/s

pip-9.0.1-py36 100% |########################################################################################| Time: 0:00:07 232.05 kB/s

#

# To activate this environment, use:

# > source activate zopencv

#

# To deactivate an active environment, use:

# > source deactivate

#

 

? ~/ source activate zopencv

(zopencv) ? ~/ conda info --envs

# conda environments:

#

zopencv               *  /Users/zz/anaconda3/envs/zopencv

root                     /Users/zz/anaconda3

 

(zopencv) ? ~/

通用的做法是创建一个env,也就是创建一个环境,使用的命令为:

?

1

conda create -n zopencv python=3.6.2

这个环境的变量叫:zopencv,使用的python版本为3.6.2
可以看到,执行完之后,会自动检测需要安装哪些依赖的库,并自动搜索安装,安装完之后会提示使用:

?

1

# > source activate zopencv

来激活这个环境,或是使用:

?

1

# > source deactivate

来关闭这个环境。
这个有什么用呢?很明显,我们可以根据需要创建多个不同版本的python环境来满足项目的需要,并且它们互相不会干扰,很方便是不是。

继续。

当然了,我们需要把它激活,这里我创建的环境变量叫:zopencv
激活后,命令行的提示符会有所变化:

?

1

2

3

4

5

6

7

(zopencv) ? ~/ conda info --envs

# conda environments:

#

zopencv               *  /Users/zz/anaconda3/envs/zopencv

root                     /Users/zz/anaconda3

 

(zopencv) ?

在提示符的开头有一对儿小括号,里面就是环境名字。表示当前的的console已经在这个环境中了。

此时,python3.6.2已经安装完了,接下来是安装opencv。

现在我在写这篇日志时已经了解到,当使用conda安装时,可以指定要安装的目标库的源地址,比如开头部分使用的那个命令:

?

1

2

3

4

5

6

7

$ conda install -c menpo opencv3

Fetching package metadata ...........

Solving package specifications: .

UnsatisfiableError: The following specifications were found to be in conflict:

  - opencv3 -> python 2.7* -> openssl 1.0.1*

  - python 3.6*

Use "conda info <package>" to see the dependencies for each package.</package>

通过install -c来指定,那么menpo到底什么呢?
它代表的是一个url,这个url源有很多的package可供使用,但是在这里,没有可用的opencv3。搜索后,我从另外一个帖子中得知,可以指定从另一个url获取opencv3
https://stackoverflow.com/questions/41873941/cant-install-opencv3-on-anaconda3-python3-6-on-macos

使用下面这句命令在自己的终端上之了一下后结果为:

?

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

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

(zopencv) ? ~/ conda search -c conda-forge --spec 'opencv=3*'

Fetching package metadata ...............

opencv                       3.1.0               np110py27_0  conda-forge

                             3.1.0               np110py34_0  conda-forge

                             3.1.0               np110py35_0  conda-forge

                             3.1.0               np111py27_0  conda-forge

                             3.1.0               np111py34_0  conda-forge

                             3.1.0               np111py35_0  conda-forge

                             3.1.0               np110py27_1  conda-forge

                             3.1.0               np110py34_1  conda-forge

                             3.1.0               np110py35_1  conda-forge

                             3.1.0               np111py27_1  conda-forge

                             3.1.0               np111py34_1  conda-forge

                             3.1.0               np111py35_1  conda-forge

                             3.1.0               np111py36_1  conda-forge

                             3.1.0               np112py27_1  conda-forge

                             3.1.0               np112py35_1  conda-forge

                             3.1.0               np112py36_1  conda-forge

                             3.2.0               np111py27_0  conda-forge

                             3.2.0               np111py35_0  conda-forge

                             3.2.0               np111py36_0  conda-forge

                             3.2.0               np112py27_0  conda-forge

                             3.2.0               np112py35_0  conda-forge

                             3.2.0               np112py36_0  conda-forge

                             3.2.0           np111py27_blas_openblas_200  conda-forge     [blas_openblas]

                             3.2.0           np111py35_blas_openblas_200  conda-forge     [blas_openblas]

                             3.2.0           np111py36_blas_openblas_200  conda-forge     [blas_openblas]

                             3.2.0           np112py27_blas_openblas_200  conda-forge     [blas_openblas]

                             3.2.0           np112py35_blas_openblas_200  conda-forge     [blas_openblas]

                             3.2.0           np112py36_blas_openblas_200  conda-forge     [blas_openblas]

                             3.2.0           np111py27_blas_openblas_201  conda-forge     [blas_openblas]

                             3.2.0           np111py35_blas_openblas_201  conda-forge     [blas_openblas]

                             3.2.0           np111py36_blas_openblas_201  conda-forge     [blas_openblas]

                             3.2.0           np112py27_blas_openblas_201  conda-forge     [blas_openblas]

                             3.2.0           np112py35_blas_openblas_201  conda-forge     [blas_openblas]

                             3.2.0           np112py36_blas_openblas_201  conda-forge     [blas_openblas]

                             3.2.0           np111py27_blas_openblas_202  conda-forge     [blas_openblas]

                             3.2.0           np111py35_blas_openblas_202  conda-forge     [blas_openblas]

                             3.2.0           np111py36_blas_openblas_202  conda-forge     [blas_openblas]

                             3.2.0           np112py27_blas_openblas_202  conda-forge     [blas_openblas]

                             3.2.0           np112py35_blas_openblas_202  conda-forge     [blas_openblas]

                             3.2.0           np112py36_blas_openblas_202  conda-forge     [blas_openblas]

                             3.2.0           np111py27_blas_openblas_203  conda-forge     [blas_openblas]

                             3.2.0           np111py35_blas_openblas_203  conda-forge     [blas_openblas]

                             3.2.0           np111py36_blas_openblas_203  conda-forge     [blas_openblas]

                             3.2.0           np112py27_blas_openblas_203  conda-forge     [blas_openblas]

                             3.2.0           np112py35_blas_openblas_203  conda-forge     [blas_openblas]

                             3.2.0           np112py36_blas_openblas_203  conda-forge     [blas_openblas]

                             3.2.0           np113py27_blas_openblas_203  conda-forge     [blas_openblas]

                             3.2.0           np113py35_blas_openblas_203  conda-forge     [blas_openblas]

                             3.2.0           np113py36_blas_openblas_203  conda-forge     [blas_openblas]

                             3.2.0           np111py27_blas_openblas_204  conda-forge     [blas_openblas]

                             3.2.0           np111py35_blas_openblas_204  conda-forge     [blas_openblas]

                             3.2.0           np111py36_blas_openblas_204  conda-forge     [blas_openblas]

                             3.2.0           np112py27_blas_openblas_204  conda-forge     [blas_openblas]

                             3.2.0           np112py35_blas_openblas_204  conda-forge     [blas_openblas]

                             3.2.0           np112py36_blas_openblas_204  conda-forge     [blas_openblas]

                             3.2.0           np113py27_blas_openblas_204  conda-forge     [blas_openblas]

                             3.2.0           np113py35_blas_openblas_204  conda-forge     [blas_openblas]

                             3.2.0           np113py36_blas_openblas_204  conda-forge     [blas_openblas]

                             3.3.0           py27_blas_openblas_200  conda-forge     [blas_openblas]

                             3.3.0           py35_blas_openblas_200  conda-forge     [blas_openblas]

                             3.3.0           py36_blas_openblas_200  conda-forge     [blas_openblas]

(zopencv) ? ~/ conda search -c conda-forge --spec 'opencv=3.3*'

Fetching package metadata ...............

opencv                       3.3.0           py27_blas_openblas_200  conda-forge     [blas_openblas]

                             3.3.0           py35_blas_openblas_200  conda-forge     [blas_openblas]

                             3.3.0           py36_blas_openblas_200  conda-forge     [blas_openblas]

(zopencv) ? ~/

看起来是有opencv3的,还是3.3.0的,对应py3.6版本。

然后就开始安装:

?

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

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

(zopencv) ? ~/ conda install -c conda-forge opencv

Fetching package metadata ...............

Solving package specifications: .

 

Package plan for installation in environment /Users/zz/anaconda3/envs/zopencv:

 

The following NEW packages will be INSTALLED:

 

    blas:        1.1-openblas                  conda-forge

    bzip2:       1.0.6-1                       conda-forge

    cairo:       1.14.6-4                      conda-forge

    ffmpeg:      3.2.4-1                       conda-forge

    fontconfig:  2.12.1-4                      conda-forge

    freetype:    2.7-1                         conda-forge

    gettext:     0.19.8.1-0                    conda-forge

    giflib:      5.1.4-0                       conda-forge

    glib:        2.51.4-0                      conda-forge

    harfbuzz:    1.3.4-2                       conda-forge

    hdf5:        1.8.18-0                      conda-forge

    icu:         58.1-1                        conda-forge

    jasper:      1.900.1-4                     conda-forge

    jpeg:        9b-1                          conda-forge

    libgfortran: 3.0.0-0                       conda-forge

    libiconv:    1.14-4                        conda-forge

    libpng:      1.6.28-0                      conda-forge

    libtiff:     4.0.6-7                       conda-forge

    libwebp:     0.5.2-7                       conda-forge

    libxml2:     2.9.5-0                       conda-forge

    numpy:       1.13.3-py36_blas_openblas_200 conda-forge [blas_openblas]

    openblas:    0.2.19-2                      conda-forge

    opencv:      3.3.0-py36_blas_openblas_200  conda-forge [blas_openblas]

    pcre:        8.39-0                        conda-forge

    pixman:      0.34.0-0                      conda-forge

    x264:        20131217-3                    conda-forge

 

Proceed ([y]/n)? y

 

bzip2-1.0.6-1. 100% |########################################################################################| Time: 0:00:03  37.51 kB/s

gettext-0.19.8 100% |########################################################################################| Time: 0:00:12 274.61 kB/s

giflib-5.1.4-0 100% |########################################################################################| Time: 0:00:01  56.57 kB/s

icu-58.1-1.tar 100% |########################################################################################| Time: 0:02:02 194.79 kB/s

jpeg-9b-1.tar. 100% |########################################################################################| Time: 0:00:02 122.74 kB/s

libgfortran-3. 100% |########################################################################################| Time: 0:00:01 282.68 kB/s

libiconv-1.14- 100% |########################################################################################| Time: 0:00:05 240.50 kB/s

pcre-8.39-0.ta 100% |########################################################################################| Time: 0:00:01 225.61 kB/s

pixman-0.34.0- 100% |########################################################################################| Time: 0:00:04 290.43 kB/s

x264-20131217- 100% |########################################################################################| Time: 0:00:12 201.70 kB/s

ffmpeg-3.2.4-1 100% |########################################################################################| Time: 0:01:20 517.16 kB/s

hdf5-1.8.18-0. 100% |########################################################################################| Time: 0:00:07 563.76 kB/s

jasper-1.900.1 100% |########################################################################################| Time: 0:00:05  59.32 kB/s

libpng-1.6.28- 100% |########################################################################################| Time: 0:00:05  55.34 kB/s

libtiff-4.0.6- 100% |########################################################################################| Time: 0:00:02 241.60 kB/s

libxml2-2.9.5- 100% |########################################################################################| Time: 0:00:05 372.49 kB/s

openblas-0.2.1 100% |########################################################################################| Time: 0:00:46 388.18 kB/s

blas-1.1-openb 100% |########################################################################################| Time: 0:00:00   1.14 MB/s

freetype-2.7-1 100% |########################################################################################| Time: 0:00:02 268.63 kB/s

libwebp-0.5.2- 100% |########################################################################################| Time: 0:00:03 195.04 kB/s

fontconfig-2.1 100% |########################################################################################| Time: 0:00:01 246.42 kB/s

glib-2.51.4-0. 100% |########################################################################################| Time: 0:00:15 337.84 kB/s

cairo-1.14.6-4 100% |########################################################################################| Time: 0:00:03 345.55 kB/s

harfbuzz-1.3.4 100% |########################################################################################| Time: 0:00:08  79.87 kB/s

numpy-1.13.3-p 100% |########################################################################################| Time: 0:00:12 310.62 kB/s

opencv-3.3.0-p  88% |#############################################################################           | Time: 0:01:16 430.01 kB/s

opencv-3.3.0-p 100% |########################################################################################| Time: 4:35:44   2.26 kB/s

 

^C

 

 

opencv-3.3.0-p 100% |########################################################################################| Time: 0:02:54 214.38 kB/s

(zopencv) ? ~/

(zopencv) ? ~/

(zopencv) ? ~/

(zopencv) ? ~/ conda install -c conda-forge opencv

Fetching package metadata ...............

Solving package specifications: .

 

# All requested packages already installed.

# packages in environment at /Users/zz/anaconda3/envs/zopencv:

#

opencv                    3.3.0           py36_blas_openblas_200  [blas_openblas]  conda-forge

(zopencv) ? ~/ conda list | grep -e python -e opencv

# packages in environment at /Users/zz/anaconda3/envs/zopencv:

opencv                    3.3.0           py36_blas_openblas_200  [blas_openblas]  conda-forge

python                    3.6.2               hd04bb42_19

(zopencv) ? ~/

中间有一段时间我去看电影了,就断开了,不过后来又接上了。

?

1

2

3

4

5

6

(zopencv) ? ~/ python

Python 3.6.2 |Anaconda, Inc.| (default, Oct  5 2017, 03:00:07)

[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import cv2

>>>

试了一下,没有问题。
把pycharm修改一下python解释器的路径,应该就可以在那里使用opencv了。
收工。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值