vnpy 安装

http://www.vnpy.org/ubuntu-tutorial.html 要求的来做

Anaconda

先到 https://www.continuum.io/downloads#linux 下 Anaconda

要 for python 2.7 的

这里有 Anaconda的 说明

在 vps 上下了好几次都报错

2017-04-08 10:28:48 (560 KB/s) - Read error at byte 142588930/484472684 (Connection reset by peer). $ wget https://repo.continuum.io/archive/Anaconda2-4.3.1-Linux-x86_64.sh

给 wget 加上断点续传

wget -c -O Anaconda2-4.3.1-Linux-x86_64.sh https://repo.continuum.io/archive/Anaconda2-4.3.1-Linux-x86_64.sh

但是没有用, 应该是服务器不支持

好在我有台双节点 vps, 先在那个上面下:

Anaconda2-4.3.1-Linux-x86_64.sh               100%[==============================================================================================>] 462.03M  48.1MB/s    in 9.5s

我还能说什么, 呵呵……

再 scp 过来

装在当前目录, 不用 sudo, 要加入 PATH 中

bash Anaconda2-4.0.0-Linux-x86_64.sh
pip install pymongo qdarkstyle
sudo apt-get install git build-essential libboost-all-dev python-dev cmake
git clone http://github.com/vnpy/vnpy.git
python vtMain.py

然后报错了

Traceback (most recent call last):
  File "vtMain.py", line 9, in <module>
    from vtEngine import MainEngine
  File "/home/vnpy/vnpy/vn.trader/vtEngine.py", line 10, in <module>
    from eventEngine import *
  File "/home/vnpy/vnpy/vn.trader/eventEngine.py", line 10, in <module>
    from PyQt4.QtCore import QTimer
ImportError: No module named PyQt4.QtCore
sudo apt-get install python-qt4

还是一样的报错

加 PYTHONPATH

export PATH=/home/vnpy/anaconda2/bin:$PATH
export PYTHONPATH=/usr/lib/python2.7/dist-packages:$PYTHONPATH

又报错

Traceback (most recent call last):
  File "vtMain.py", line 9, in <module>
    from vtEngine import MainEngine
  File "/home/vnpy/vnpy/vn.trader/vtEngine.py", line 14, in <module>
    from ctaAlgo.ctaEngine import CtaEngine
  File "/home/vnpy/vnpy/vn.trader/ctaAlgo/ctaEngine.py", line 26, in <module>
    from strategy import STRATEGY_CLASS
  File "/home/vnpy/vnpy/vn.trader/ctaAlgo/strategy/__init__.py", line 25, in <module>
    module = importlib.import_module(moduleName)
  File "/home/vnpy/anaconda2/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/vnpy/vnpy/vn.trader/ctaAlgo/strategy/strategyAtrRsi.py", line 17, in <module>
    import talib
ImportError: No module named talib
pip install ta-lib

编译时报错了

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/vnpy/anaconda2/lib/python2.7/site-packages/numpy/core/include -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/home/vnpy/anaconda2/include/python2.7 -c talib/common.c -o build/temp.linux-x86_64-2.7/talib/common.o

talib/common.c:242:28: fatal error: ta-lib/ta_defs.h: No such file or directory

 #include "ta-lib/ta_defs.h"

                            ^

compilation terminated.

error: command 'gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /home/vnpy/anaconda2/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_vnpy/ta-lib/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-MSqG0K-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_vnpy/ta-lib
Storing debug log for failure in /home/vnpy/.pip/pip.log

按这里说的, 先下载编译 https://mrjbq7.github.io/ta-lib/install.html

然后再次安装 ta-lib 时又报错了

AttributeError: install_layout

----------------------------------------
Cleaning up...
Command /home/vnpy/anaconda2/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_vnpy/ta-lib/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().
replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-8xSIFQ-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/
pip_build_vnpy/ta-lib
Traceback (most recent call last):
  File "/home/vnpy/anaconda2/bin/pip", line 6, in <module>
    sys.exit(pip.main())
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 235, in main
    return command.main(cmd_args)
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 30: ordinal not in range(128)

下源码来装成功 https://github.com/mrjbq7/ta-lib

然后又报错:

Traceback (most recent call last):
  File "vtMain.py", line 10, in <module>
    from uiMainWindow import *
  File "/home/vnpy/vnpy/vn.trader/uiMainWindow.py", line 3, in <module>
    import psutil
  File "/usr/lib/python2.7/dist-packages/psutil/__init__.py", line 88, in <module>
    import psutil._pslinux as _psplatform
  File "/usr/lib/python2.7/dist-packages/psutil/_pslinux.py", line 20, in <module>
    import _psutil_linux
ImportError: No module named _psutil_linux

卸载

sudo apt-get remove python-psutil