Linux下Miniconda量化环境安装

前言

linux目录相关知识

/usr:系统级的目录,可以理解为C:/Windows/,/usr/lib理解为C:/Windows/System32。
/usr/local:用户级的程序目录,可以理解为C:/Progrem Files/。用户自己编译的软件默认会安装到这个目录下。
/opt:用户级的程序目录,可以理解为D:/Software,opt有可选的意思,这里可以用于放置第三方大型软件(或游戏),当你不需要时,直接rm -rf掉即可。在硬盘容量不够时,也可将/opt单独挂载到其他磁盘上使用。

源码放哪里?
/usr/src:系统级的源码目录。
/usr/local/src:用户级的源码目录。

准备
安装bzip2

[root@bitquant ~]# yum install -y bzip2

1、Miniconda下载

注:4.5.12的miniconda3版本在安装talib时会降级到py2,所以这里指定4.5.11的版本,而不是取 Miniconda3-latest-Linux-x86_64.sh

[root@BTCQUANT ~]# wget https://repo.continuum.io/miniconda/Miniconda3-4.5.11-Linux-x86_64.sh
--2019-03-15 18:14:23--  https://repo.continuum.io/miniconda/Miniconda3-4.5.11-Linux-x86_64.sh
Resolving repo.continuum.io (repo.continuum.io)... 104.18.201.79, 104.18.200.79, 2606:4700::6812:c84f, ...
Connecting to repo.continuum.io (repo.continuum.io)|104.18.201.79|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 62574861 (60M) [application/x-sh]
Saving to: ‘Miniconda3-4.5.11-Linux-x86_64.sh100%[===================================================================================================================================>] 62,574,861  12.3MB/s   in 3.9s   

2019-03-15 18:14:26 (15.5 MB/s) - ‘Miniconda3-4.5.11-Linux-x86_64.sh’ saved [62574861/62574861]



2. 安装

[root@bitquant ~]# sh Miniconda3-4.5.11-Linux-x86_64.sh

Welcome to Miniconda3 4.5.11

In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>> 
===================================
Miniconda End User License Agreement
===================================
......


Do you accept the license terms? [yes|no]
[no] >>> yes

Miniconda3 will now be installed into this location:
/root/miniconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/root/miniconda3] >>> /usr/local/miniconda3
PREFIX=/usr/local/miniconda3
installing: python-3.7.0-hc3d631a_0 ...
Python 3.7.0
installing...
......

installation finished.
Do you wish the installer to prepend the Miniconda3 install location
to PATH in your /root/.bashrc ? [yes|no]
[no] >>> yes

Appending source /usr/local/miniconda3/bin/activate to /root/.bashrc
A backup will be made to: /root/.bashrc-miniconda3.bak


For this change to become active, you have to open a new terminal.

Thank you for installing Miniconda3!
[root@FANGBEI ~]# 

3、重新连接ssh,进入新的terminal

测试python

[root@FANGBEI ~]# python
Python 3.7.0 (default, Jun 28 2018, 13:15:42) 
[GCC 7.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

4、安装Ta-lib

[root@FANGBEI ~]# conda install -c quantopian ta-lib
Solving environment: done

## Package Plan ##

  environment location: /usr/local/miniconda3

  added / updated specs: 
    - ta-lib


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    asn1crypto-0.24.0          |           py35_0         156 KB
    setuptools-40.2.0          |           py35_0         571 KB
    pip-10.0.1                 |           py35_0         1.8 MB
    numpy-1.14.6               |   py35h3b04361_4          46 KB
    cryptography-2.3.1         |   py35hc365091_0         585 KB
    mkl_random-1.0.1           |   py35h4414c95_1         362 KB
    libgfortran-ng-7.3.0       |       hdf63c60_0         1.3 MB
    six-1.11.0                 |           py35_1          21 KB
    pycparser-2.19             |           py35_0         175 KB
    python-3.5.6               |       hc3d631a_0        28.3 MB
    mkl-2019.0                 |              118       204.4 MB
    idna-2.7                   |           py35_0         133 KB
    pyopenssl-18.0.0           |           py35_0          82 KB
    wheel-0.31.1               |           py35_0          63 KB
    intel-openmp-2019.0        |              118         721 KB
    requests-2.19.1            |           py35_0          97 KB
    ta-lib-0.4.9               |      np114py35_0         2.6 MB  quantopian
    pycosat-0.6.3              |   py35h14c3975_0         105 KB
    certifi-2018.8.24          |           py35_1         139 KB
    conda-4.5.11               |           py35_0         1.0 MB
    ruamel_yaml-0.15.46        |   py35h14c3975_0         243 KB
    cffi-1.11.5                |   py35he75722e_1         213 KB
    numpy-base-1.14.6          |   py35h81de0dd_4         4.1 MB
    urllib3-1.23               |           py35_0         153 KB
    mkl_fft-1.0.6              |   py35h7dd41cf_0         149 KB
    chardet-3.0.4              |           py35_1         191 KB
    pysocks-1.6.8              |           py35_0          22 KB
    blas-1.0                   |              mkl           6 KB
    ------------------------------------------------------------
                                           Total:       247.6 MB

The following NEW packages will be INSTALLED:

    blas:           1.0-mkl                          
    intel-openmp:   2019.0-118                       
    libgfortran-ng: 7.3.0-hdf63c60_0                 
    mkl:            2019.0-118                       
    mkl_fft:        1.0.6-py35h7dd41cf_0             
    mkl_random:     1.0.1-py35h4414c95_1             
    numpy:          1.14.6-py35h3b04361_4            
    numpy-base:     1.14.6-py35h81de0dd_4            
    ta-lib:         0.4.9-np114py35_0      quantopian

The following packages will be UPDATED:

    asn1crypto:     0.24.0-py37_0                     --> 0.24.0-py35_0         
    certifi:        2018.8.24-py37_1                  --> 2018.8.24-py35_1      
    cffi:           1.11.5-py37he75722e_1             --> 1.11.5-py35he75722e_1 
    chardet:        3.0.4-py37_1                      --> 3.0.4-py35_1          
    conda:          4.5.11-py37_0                     --> 4.5.11-py35_0         
    cryptography:   2.3.1-py37hc365091_0              --> 2.3.1-py35hc365091_0  
    idna:           2.7-py37_0                        --> 2.7-py35_0            
    pip:            10.0.1-py37_0                     --> 10.0.1-py35_0         
    pycosat:        0.6.3-py37h14c3975_0              --> 0.6.3-py35h14c3975_0  
    pycparser:      2.18-py37_1                       --> 2.19-py35_0           
    pyopenssl:      18.0.0-py37_0                     --> 18.0.0-py35_0         
    pysocks:        1.6.8-py37_0                      --> 1.6.8-py35_0          
    requests:       2.19.1-py37_0                     --> 2.19.1-py35_0         
    ruamel_yaml:    0.15.46-py37h14c3975_0            --> 0.15.46-py35h14c3975_0
    setuptools:     40.2.0-py37_0                     --> 40.2.0-py35_0         
    six:            1.11.0-py37_1                     --> 1.11.0-py35_1         
    urllib3:        1.23-py37_0                       --> 1.23-py35_0           
    wheel:          0.31.1-py37_0                     --> 0.31.1-py35_0         

The following packages will be DOWNGRADED:

    python:         3.7.0-hc3d631a_0                  --> 3.5.6-hc3d631a_0      

Proceed ([y]/n)? y


Downloading and Extracting Packages
asn1crypto-0.24.0    | 156 KB    | ################################################################################################################# | 100% 
setuptools-40.2.0    | 571 KB    | ################################################################################################################# | 100% 
pip-10.0.1           | 1.8 MB    | ################################################################################################################# | 100% 
numpy-1.14.6         | 46 KB     | ################################################################################################################# | 100% 
cryptography-2.3.1   | 585 KB    | ################################################################################################################# | 100% 
mkl_random-1.0.1     | 362 KB    | ################################################################################################################# | 100% 
libgfortran-ng-7.3.0 | 1.3 MB    | ################################################################################################################# | 100% 
six-1.11.0           | 21 KB     | ################################################################################################################# | 100% 
pycparser-2.19       | 175 KB    | ################################################################################################################# | 100% 
python-3.5.6         | 28.3 MB   | ################################################################################################################# | 100% 
mkl-2019.0           | 204.4 MB  | ################################################################################################################# | 100% 
idna-2.7             | 133 KB    | ################################################################################################################# | 100% 
pyopenssl-18.0.0     | 82 KB     | ################################################################################################################# | 100% 
wheel-0.31.1         | 63 KB     | ################################################################################################################# | 100% 
intel-openmp-2019.0  | 721 KB    | ################################################################################################################# | 100% 
requests-2.19.1      | 97 KB     | ################################################################################################################# | 100% 
ta-lib-0.4.9         | 2.6 MB    | ################################################################################################################# | 100% 
pycosat-0.6.3        | 105 KB    | ################################################################################################################# | 100% 
certifi-2018.8.24    | 139 KB    | ################################################################################################################# | 100% 
conda-4.5.11         | 1.0 MB    | ################################################################################################################# | 100% 
ruamel_yaml-0.15.46  | 243 KB    | ################################################################################################################# | 100% 
cffi-1.11.5          | 213 KB    | ################################################################################################################# | 100% 
numpy-base-1.14.6    | 4.1 MB    | ################################################################################################################# | 100% 
urllib3-1.23         | 153 KB    | ################################################################################################################# | 100% 
mkl_fft-1.0.6        | 149 KB    | ################################################################################################################# | 100% 
chardet-3.0.4        | 191 KB    | ################################################################################################################# | 100% 
pysocks-1.6.8        | 22 KB     | ################################################################################################################# | 100% 
blas-1.0             | 6 KB      | ################################################################################################################# | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
[root@FANGBEI ~]# 
[root@FANGBEI ~]# 
[root@FANGBEI ~]# 
[root@FANGBEI ~]# 
[root@FANGBEI ~]# python
Python 3.5.6 |Anaconda, Inc.| (default, Aug 26 2018, 21:41:56) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import talib
>>> exit()
[root@FANGBEI ~]# 

其他库

[root@BTCQUANT ~]# pip install PyMySQL
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting PyMySQL
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/ed/39/15045ae46f2a123019aa968dfcba0396c161c20f855f11dea6796bcaae95/PyMySQL-0.9.3-py2.py3-none-any.whl (47kB)
    100% |████████████████████████████████| 51kB 44.5MB/s 
mkl-random 1.0.1 requires cython, which is not installed.
Installing collected packages: PyMySQL
Successfully installed PyMySQL-0.9.3



[root@BTCQUANT ~]# pip install numba
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting numba
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/8c/0e/96af4929b5cf75fa9db37889fd4a06c7ca392162c47066649575a2e41f2f/numba-0.43.0-cp35-cp35m-manylinux1_x86_64.whl (3.3MB)
    100% |████████████████████████████████| 3.3MB 89.3MB/s 
Collecting llvmlite>=0.28.0dev0 (from numba)
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/d9/20/3086d4970454dc95bc3b702086d2cf6410ed5629bc70894d8c147cf98b9c/llvmlite-0.28.0-cp35-cp35m-manylinux1_x86_64.whl (17.1MB)
    100% |████████████████████████████████| 17.1MB 99.5MB/s 
Requirement already satisfied: numpy in /usr/local/miniconda3/lib/python3.5/site-packages (from numba) (1.14.6)
Installing collected packages: llvmlite, numba
Successfully installed llvmlite-0.28.0 numba-0.43.0


[root@BTCQUANT ~]# pip install websocket-client
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting websocket-client
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/38/54/684db2ba1b7a203602808446b8686ee786f93b4a7e080cdc440cc7e06e56/websocket_client-0.55.0-py2.py3-none-any.whl (200kB)
    100% |████████████████████████████████| 204kB 78.7MB/s 
Requirement already satisfied: six in /usr/local/miniconda3/lib/python3.5/site-packages (from websocket-client) (1.11.0)
Installing collected packages: websocket-client
Successfully installed websocket-client-0.55.0
原文地址:https://www.cnblogs.com/bitquant/p/linux-miniconda3.html