[关闭]
@Perfect-Demo 2019-08-29T16:07:12.000000Z 字数 2410 阅读 5505

命令行安装Anaconda并配置(python和c++版本的)opencv+dlib

Linux命令行安装环境


1. 首先安装anaconda

先下载Anaconda

  1. wget https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh
  2. //注意这个版本可以先去官网看

进入安装文件存放的目录

  1. 这里自己来

开始安装

  1. bash Anaconda3-5.1.0-Linux-x86_64.sh
  2. //注意版本号

根据提示按ENTER

  1. Welcome to Anaconda3 5.1.0 (by Continuum Analytics, Inc.)
  2. In order to continue the installation process, please review the license
  3. agreement.
  4. Please, press ENTER to continue
  5. >>>

根据提示输入yes,同意license agreement

  1. ... ...
  2. kerberos (krb5, non-Windows platforms)
  3. A network authentication protocol designed to provide strong authentication
  4. for client/server applications by using secret-key cryptography.
  5. cryptography
  6. A Python library which exposes cryptographic recipes and primitives.
  7. Do you approve the license terms? [yes|no]
  8. >>> yes

直接ENTER键,用默认的安装路径

  1. Anaconda3 will now be installed into this location:
  2. /root/anaconda3
  3. - Press ENTER to confirm the location
  4. - Press CTRL-C to abort the installation
  5. - Or specify a different location below
  6. [/root/anaconda2] >>>

写入环境变量,直接输入yes

  1. ... ...
  2. installing: zlib-1.2.8-3 ...
  3. installing: anaconda-4.4.0-np112py27_0 ...
  4. installing: conda-4.3.21-py27_0 ...
  5. installing: conda-env-2.6.0-0 ...
  6. Python 2.7.13 :: Continuum Analytics, Inc.
  7. creating default environment...
  8. installation finished.
  9. Do you wish the installer to prepend the Anaconda2 install location
  10. to PATH in your /root/.bashrc ? [yes|no]
  11. [no] >>> yes

生效.bashrc文件

  1. source ~/.bashrc

输入python,验证环境

  1. Python 2.7.13 |Anaconda 4.4.0 (64-bit)| (default, Dec 20 2016, 23:09:15)
  2. [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
  3. Type "help", "copyright", "credits" or "license" for more information.
  4. Anaconda is brought to you by Continuum Analytics.
  5. Please check out: http://continuum.io/thanks and https://anaconda.org
  6. >>>

2. Opencv3安装

一般情况下,你会发现opencv3,安装起来,真的好麻烦,这里我发现一个好方法:

1. 先把你的Linux中anaconda的源换成清华镜像:
  1. conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  2. conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  3. conda config --set show_channel_urls yesconda config --add channels http

另外opencv3 c++ 安装有一个巨大的坑,就是如果你先装好了anaconda,并且设置好了环境变量,那么安装opencv c++编译的时候,本来要到/usr/local里找的东西,会由于环境变量的原因先去ananconda的安装环境里找,这样就会报错(本来按道理camke的时候设置了参数到/usr/local里找,但是很奇怪好像没有起作用。)如果你先安装好了anaconda,那也没关系,给anaconda的文件夹改个名,随便改什么,只要不让opencv跑到那里面找文件就行。
装完之后,把名字改回来就好,这样anaconda也可以用,opencv也可以用。

2. 然后就可以在你需要安装的环境下安装Opencv3了
  1. conda install --channel https://conda.anaconda.org/menpo opencv3

3. dlib安装

由于dlib库在anaconda中没有官方提供,所以属于用conda安装第三方库
和opencv一样,本来又是要各种make源码编译的,但是这里有一个好方法,一句话解决(当然,是在anaconda下啦)
  1. conda install -c menpo dlib=18.18

但是注意,这句话的话,可能会导致安装之后少了一些功能,现在有一种更好的方法:

  1. conda install -c menpo dlib
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注