Linux下Miniconda量化环境安装

时间:2023-03-10 06:30:10
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
---- ::--  https://repo.continuum.io/miniconda/Miniconda3-4.5.11-Linux-x86_64.sh
Resolving repo.continuum.io (repo.continuum.io)... ::::c84f, ...
Connecting to repo.continuum.io (repo.continuum.io)|... connected.
HTTP request sent, awaiting response...  OK
Length:  (60M) [application/x-sh]
Saving to: ‘Miniconda3--Linux-x86_64.sh’

%[===================================================================================================================================>] ,,  .3MB/s   .9s   

-- :: (-Linux-x86_64./]

2. 安装

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

Welcome to Miniconda3 

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--hc3d631a_0 ...
Python
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  (default, Jun  , ::)
[GCC ] :: 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-          |           py35_0          KB
    setuptools-          |           py35_0          KB
    pip-                 |           py35_0         1.8 MB
    numpy-               |   py35h3b04361_4           KB
    cryptography-         |   py35hc365091_0          KB
    mkl_random-           |   py35h4414c95_1          KB
    libgfortran-ng-       |       hdf63c60_0         1.3 MB
    six-                 |           py35_1           KB
    pycparser- KB
    python-               |       hc3d631a_0        28.3 MB
    mkl-       204.4 MB
    idna- KB
    pyopenssl-           |           py35_0           KB
    wheel-               |           py35_0           KB
    intel-openmp-          KB
    requests-            |           py35_0           KB
    ta-lib-               |      np114py35_0         2.6 MB  quantopian
    pycosat-              |   py35h14c3975_0          KB
    certifi-          |           py35_1          KB
    conda-               |           py35_0         1.0 MB
    ruamel_yaml-        |   py35h14c3975_0          KB
    cffi-                |   py35he75722e_1          KB
    numpy-base-          |   py35h81de0dd_4         4.1 MB
    urllib3- KB
    mkl_fft-              |   py35h7dd41cf_0          KB
    chardet-              |           py35_1          KB
    pysocks-              |           py35_0           KB
    blas- KB
    ------------------------------------------------------------
                                           Total:       247.6 MB

The following NEW packages will be INSTALLED:

    blas:           1.0-mkl
    intel-openmp:
    libgfortran-ng: -hdf63c60_0
    mkl:
    mkl_fft:        -py35h7dd41cf_0
    mkl_random:     -py35h4414c95_1
    numpy:          -py35h3b04361_4
    numpy-base:     -py35h81de0dd_4
    ta-lib:         -np114py35_0      quantopian

The following packages will be UPDATED:

    asn1crypto:     -py37_0                     --> -py35_0
    certifi:        -py37_1                  --> -py35_1
    cffi:           -py37he75722e_1             --> -py35he75722e_1
    chardet:        -py37_1                      --> -py35_1
    conda:          -py37_0                     --> -py35_0
    cryptography:   -py37hc365091_0              --> -py35hc365091_0
    idna:           2.7-py37_0                        --> 2.7-py35_0
    pip:            -py37_0                     --> -py35_0
    pycosat:        -py37h14c3975_0              --> -py35h14c3975_0
    pycparser:      2.18-py37_1                       --> 2.19-py35_0
    pyopenssl:      -py37_0                     --> -py35_0
    pysocks:        -py37_0                      --> -py35_0
    requests:       -py37_0                     --> -py35_0
    ruamel_yaml:    -py37h14c3975_0            --> -py35h14c3975_0
    setuptools:     -py37_0                     --> -py35_0
    six:            -py37_1                     --> -py35_1
    urllib3:        1.23-py37_0                       --> 1.23-py35_0
    wheel:          -py37_0                     --> -py35_0         

The following packages will be DOWNGRADED:

    python:         -hc3d631a_0                  --> -hc3d631a_0      

Proceed ([y]/n)? y

Downloading and Extracting Packages
asn1crypto-    |  KB    | ################################################################################################################# | %
setuptools-    |  KB    | ################################################################################################################# | %
pip-           | %
numpy-         |  KB     | ################################################################################################################# | %
cryptography-   |  KB    | ################################################################################################################# | %
mkl_random-     |  KB    | ################################################################################################################# | %
libgfortran-ng- | %
six-           |  KB     | ################################################################################################################# | %
pycparser- KB    | ################################################################################################################# | %
python-         | %
mkl-%
idna- KB    | ################################################################################################################# | %
pyopenssl-     |  KB     | ################################################################################################################# | %
wheel-         |  KB     | ################################################################################################################# | %
intel-openmp- KB    | ################################################################################################################# | %
requests-      |  KB     | ################################################################################################################# | %
ta-lib-         | %
pycosat-        |  KB    | ################################################################################################################# | %
certifi-    |  KB    | ################################################################################################################# | %
conda-         | %
ruamel_yaml-  |  KB    | ################################################################################################################# | %
cffi-          |  KB    | ################################################################################################################# | %
numpy-base-    | %
urllib3- KB    | ################################################################################################################# | %
mkl_fft-        |  KB    | ################################################################################################################# | %
chardet-        |  KB    | ################################################################################################################# | %
pysocks-        |  KB     | ################################################################################################################# | %
blas- KB      | ################################################################################################################# | %
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
[root@FANGBEI ~]#
[root@FANGBEI ~]#
[root@FANGBEI ~]#
[root@FANGBEI ~]#
[root@FANGBEI ~]# python
Python  |Anaconda, Inc.| (default, Aug  , ::)
[GCC ] 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)
    % |████████████████████████████████| 51kB .5MB/s
mkl-random  requires cython, which is not installed.
Installing collected packages: PyMySQL
Successfully installed PyMySQL-

[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)
    % |████████████████████████████████| .3MB .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)
    % |████████████████████████████████| .1MB .5MB/s
Requirement already satisfied: numpy /site-packages (from numba) ()
Installing collected packages: llvmlite, numba
Successfully installed llvmlite- numba-

[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)
    % |████████████████████████████████| 204kB .7MB/s
Requirement already satisfied: six /site-packages (from websocket-client) ()
Installing collected packages: websocket-client
Successfully installed websocket-client-