python run.py 报错: File "/home/john/anaconda3/envs/vnpy27/lib/python2.7/site-packages/vnpy-1.9.2-py2.7.egg/vnpy/event/eventEngine.py", line 11, in <module> from qtpy.QtCore import QTimer File "/home/john/anaconda3/envs/vnpy27/lib/python2.7/site-packages/qtpy/__init__.py", line 208, in <module> raise PythonQtError('No Qt bindings could be found') qtpy.PythonQtError: No Qt bindings could be found 进入python窗口,import qtpy确实无法import
cd ~/下载/PyQt4_gpl_x11-4.12.1 sudo python configure-ng.py sudo make sudo make install 依然不行。
百度下报错提示:qtpy.PythonQtError: No Qt bindings could be found 参考:https://github.com/spyder-ide/spyder/issues/3545 执行: pip uninstall spyder pip install spyder==3.2.1 报错:pylint requires Python '>=3.4.*' but the running Python is 2.7.11 忽略,不使用这种解决方式。
cd ~/PYTHON/vnpy/examples/VnTrader python run.py 报错: File “/home/john/anaconda3/envs/vnpy27/lib/python2.7/site-packages/vnpy-1.9.2-py2.7.egg/vnpy/api/rest/RestClient.py”, line 11, in from enum import Enum ImportError: No module named enum pip install enum 成功!
cd ~/PYTHON/vnpy/examples/VnTrader python run.py 报错: File “/home/john/anaconda3/envs/vnpy27/lib/python2.7/site-packages/vnpy-1.9.2-py2.7.egg/vnpy/api/rest/RestClient.py”, line 12, in from typing import Any, Callable, Optional ImportError: No module named typing pip install typing 成功
cd ~/PYTHON/vnpy/examples/VnTrader python run.py 报错: File “/home/john/anaconda3/envs/vnpy27/lib/python2.7/site-packages/vnpy-1.9.2-py2.7.egg/vnpy/api/xtp/init.py”, line 4, in from .vnxtpquote import QuoteApi ImportError: libsodium.so.18: cannot open shared object file: No such file or directory 参考:https://mrxn.net/Linux/541.html 执行: find / -name “libsodium.so.18” 2>/dev/null sudo ln -sf /home/john/anaconda3/pkgs/libsodium-1.0.10-0/lib/libsodium.so.18 /usr/lib/libsodium.so.18 sudo ldconfig python run.py 依然是同样的报错: File “/home/john/anaconda3/envs/vnpy27/lib/python2.7/site-packages/vnpy-1.9.2-py2.7.egg/vnpy/api/xtp/init.py”, line 4, in from .vnxtpquote import QuoteApi ImportError: libsodium.so.18: cannot open shared object file: No such file or directory 参考:https://blog.csdn.net/baidu_27518829/article/details/88383775 执行: conda install -c conda-forge libsodium python run.py 依然是同样的报错。 参考:https://github.com/vnpy/vnpy/issues/1364 执行: sudo apt-get install libsodium-dev cd /home/john/PYTHON/vnpy/vnpy/api/xtp bash build.sh python run.py 依然是同样的报错。 参考:同上 执行: sudo gedit run.py 注释掉加载xtpGateway的代码
python run.py 报错: File “/home/john/anaconda3/envs/vnpy27/lib/python2.7/site-packages/vnpy-1.9.2-py2.7.egg/vnpy/rpc/vnrpc.py”, line 7, in import zmq ImportError: No module named zmq 执行:pip install zmq
python run.py 报错: File “run.py”, line 65, in main me.addGateway(xtpGateway) NameError: global name ‘xtpGateway’ is not defined 执行:sudo gedit run.py 有个地方漏掉了,没注释干净 python run.py 启动起来了,但是没有行情,有账户信息没有配置
vnpy1.9问题补充(20190510接上)
卸载旧vnpy1.9
卸载之前pip安装的vnpy1.9版本,否则和代码中重复了,不知道执行代码还是包里的vnpy
1
pip uninstall vnpy
报错No module named matplotlib
1 2 3 4
报错:ImportError: No module named matplotlib.ticker
解决: conda install matplotlib
报错No module named statsmodels
1 2 3 4 5
File "/root/anaconda3/envs/vnpy27/lib/python2.7/site-packages/vnpy-1.9.2-py2.7.egg/vnpy/trader/app/ctaStrategy/ctaBacktesting.py", line 38, in <module> import statsmodels.api as sm # 最小二 ImportError: No module named statsmodels.api 解决: conda install statsmodels
报错cannot import name AbstractMethodError
1 2 3 4 5 6 7
报错: File "/root/anaconda3/envs/vnpy27/lib/python2.7/site-packages/pandas/core/groupby/groupby.py", line 23, in <module> from pandas.errors import AbstractMethodError ImportError: cannot import name AbstractMethodError
CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: CTPAPI_MD_LIBRARY linked by target "vnctpmd" in directory /home/john/PYTHON/vnpy19/vnpy/api/ctp CTPAPI_TD_LIBRARY linked by target "vnctptd" in directory /home/john/PYTHON/vnpy19/vnpy/api/ctp
-- Configuring incomplete, errors occurred! See also "/home/john/PYTHON/vnpy19/vnpy/api/ctp/build/CMakeFiles/CMakeOutput.log". See also "/home/john/PYTHON/vnpy19/vnpy/api/ctp/build/CMakeFiles/CMakeError.log".
如果不理会,直接pycharm执行example下面的run 报错: File "/home/john/PYTHON/vnpy19/vnpy/api/ctp/__init__.py", line 4, in <module> from .vnctpmd import MdApi ImportError: libthostmduserapi.so: cannot open shared object file: No such file or directory
Traceback (most recent call last): File "run.py", line 28, in <module> from vnpy.trader.gateway import (ibGateway, huobiGateway, okexfGateway, okexGateway, ccxtGateway, File "/root/anaconda3/envs/vnpy27/lib/python2.7/site-packages/vnpy-1.9.2-py2.7.egg/vnpy/trader/gateway/ctptestGateway/__init__.py", line 5, in <module> from .ctptestGateway import CtptestGateway File "/root/anaconda3/envs/vnpy27/lib/python2.7/site-packages/vnpy-1.9.2-py2.7.egg/vnpy/trader/gateway/ctptestGateway/ctptestGateway.py", line 16, in <module> from vnctpmd import MdApi ImportError: libboost_python-py27.so.1.65.1: cannot open shared object file: No such file or directory
ls 编译前后路径是否有文件缺失 ls -alh ~/PYTHON/vnpy19/vnpy/trader/gateway/ctptestGateway ls -alh /root/anaconda3/envs/vnpy27/lib/python2.7/site-packages/vnpy-1.9.2-py2.7.egg/vnpy/trader/gateway/ctptestGateway/ 无缺失(pyc无关)
wget https://dl.bintray.com/boostorg/release/1.65.1/source/boost_1_65_1.tar.gz \ && tar zxf boost_1_65_1.tar.gz \ && cd boost_1_65_1 \ && ./bootstrap.sh --with-libraries=python --with-python=python2.7 \ && ./b2 install
卸载手工安装libboost,集成方式重新安装 sudo apt-get autoremove libboost-dev 搜索之前自己笔记:sudo apt-get install libboost-all-dev 执行vnpy的install.sh安装脚本 报错 CMake Error at /usr/share/cmake-3.5/Modules/FindBoost.cmake:1677 (message): Unable to find the requested Boost libraries. Boost version: 1.65.1 Boost include path: /usr/local/include Could not find the following Boost libraries: boost_thread boost_date_time boost_system
Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost. Call Stack (most recent call first): CMakeLists.txt:83 (find_package) 所以:直接信息Boost include path: /usr/local/include,配置错了 或者BOOST_LIBRARYDIR,BOOST_ROOT配置错了或为配置 在安装libboost-all-dev的日志其实有libboost_thread等这一坨信息,但是未找到 尝试1, export Boost_INCLUDE_DIR=/usr/local/include/boost/ 不行。 尝试2,find / -name libboost_th* /usr/lib/x86_64-linux-gnu/libboost_thread.a /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.58.0 /usr/lib/x86_64-linux-gnu/libboost_thread.so export BOOST_LIBRARYDIR=/usr/lib/x86_64-linux-gnu/ ok了。 这个网上查询到资料和自己不一致,很大可能是自己root登录,软件默认位置和他人大多数不同,导致按照他人方案不可性。
切换到git pull的源代码路径 报错:ModuleNotFoundError: No module named ‘vnpy.api.ctp.vnctpmd’
1 2 3 4 5 6 7 8 9 10 11 12 13
ModuleNotFoundError: No module named 'vnpy.api.ctp.vnctpmd' 参考:https://github.com/vnpy/vnpy/issues/1686 To add '.so' on Linux https://github.com/vnpy/vnpy/pull/1693 就是说需要执行python setup.py build ;python setup.py install 自己和1.9比对摸索看出门道了 build里面的lib中找下,build/lib/vnpy/api/ctp,下面有个vnctpmd.so或者vnctptd.so的copy到vnpy/api/ctp路径下下即可 注意1,build里面的lib,这个可能有多个,lib.linuxx64,lib.temp,等,找一个对应路径有so的,我这里有build下面有4个lib开始文件夹,但仅有一个相应位置有so文件,其他都是干扰项 注意2,vnctpmd.so和vnctptd.so的名字可能不完全一样,比如vnctptd.xxxxxxxx.so,vnctpmd.xxxxxxx.so等,只要vnctpmd开头so结尾就算满足条件了。 注意3,如果都没有,满足条件so,则编译生成下 项目根路径/setup.py里面有编译脚本 执行:python setup.py build即可。
3,次日启动发现启动又不行了,pycharm也不行
pycharm中启动 报错
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
File "/home/john/PYTHON/vnpy20/vnpy/event/eventEngine.py", line 11, in <module> from qtpy.QtCore import QTimer ModuleNotFoundError: No module named 'qtpy'
新报错 Traceback (most recent call last): File "/home/john/PYTHON/vnpy20/run.py", line 2, in <module> from vnpy.trader.engine import MainEngine ModuleNotFoundError: No module named 'vnpy.trader.engine' 同时pycharm提示一堆缺少没有安装的。