vnpy_vnpy20异常错误

vnpy2.0安装后报错ModuleNotFoundError: No module named ‘vnpy.api.ctp.vnctpmd’

1,git clone vnpy的代码
2,安装bash install.sh
3,新建run.py
copy如下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from vnpy.event import EventEngine
from vnpy.trader.engine import MainEngine
from vnpy.trader.ui import MainWindow, create_qapp
from vnpy.gateway.ctp import CtpGateway
from vnpy.app.cta_strategy import CtaStrategyApp
from vnpy.app.cta_backtester import CtaBacktesterApp

def main():
"""Start VN Trader"""
qapp = create_qapp()

event_engine = EventEngine()
main_engine = MainEngine(event_engine)

main_engine.add_gateway(CtpGateway)
main_engine.add_app(CtaStrategyApp)
main_engine.add_app(CtaBacktesterApp)

main_window = MainWindow(main_engine, event_engine)
main_window.showMaximized()

qapp.exec()

if __name__ == "__main__":
main()

python run.py
报错:ModuleNotFoundError: No module named ‘vnpy.api.ctp.vnctpmd’
原因:ctp这一坨都是c相关代码,所以肯定是缺少了c相关代码导致,ctp目录下看到了dll文件,没看到so文件
所以应该是作者忘了放so文件了
setup.py里面有编译脚本
python setup.py build && python setup.py install
然后项目的vnpy/bulid/lib/vnpy/api/ctp/vnctpmd.so和vnctptd.so拷贝到vnpy/vnpy/api/ctp/下面就行了
再次执行python run.py有界面了

注意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,如果还报错,注意报错是否是无关的接口,比如xtp.so,uft.so等等,是的话从run.py中移除相关代码和import即可.

报错:fatal error: string_view: 没有那个文件或目录

vnpy/api/oes/vnoes/include/c2py/property_helper.hpp:5:23: fatal error: string_view: 没有那个文件或目录
问题原因:gcc版本问题
解决:gcc升级到7.0+

1
2
3
4
5
6
sudo add-apt-repository ppa:jonathonf/gcc-7.1
sudo apt-get update
sudo apt-get install gcc-7 g++-7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7

验证:gcc -v

参考:https://github.com/vnpy/vnpy/issues/1911
https://blog.csdn.net/DuanLiuchang/article/details/103001853

bash install.sh时报错,sed: 无法打开临时文件 /etc/sedXXFsLF: 权限不够

1
2
3
4
Collecting psycopg2
xxx
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
sed: 无法打开临时文件 /etc/sedXXFsLF: 权限不够

解决:conda install psycopg2

cannot import name ‘Qsci’ from ‘PyQt5’

解决01:pip install QScintilla

1
2
3
4
依然报错:
File "/home/john/PYTHON/vnpy20/vnpy/trader/ui/editor.py", line 4, in <module>
from PyQt5 import QtWidgets, Qsci, QtGui
ImportError: /home/john/anaconda3/envs/vnpy20/lib/python3.7/site-packages/PyQt5/../../../libQt5Core.so.5: version `Qt_5.13' not found (required by /home/john/anaconda3/envs/vnpy20/lib/python3.7/site-packages/PyQt5/Qsci.so)

解决02:pip install QScintilla==2.11.3 (如果无法安装,尝试su到root或其他主用户,sudo可能不好使)
提示:已满足

解决03:pip install pyqt5==5.13
问题转移到新问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
报错:
File "/home/john/PYTHON/vnpy20/vnpy/trader/ui/editor.py", line 4, in <module>
from PyQt5 import QtWidgets, Qsci, QtGui
RuntimeError: the sip module implements API v12.0 to v12.6 but the PyQt5.Qsci module requires API v12.7

解决:
pip uninstall sip
pip install sip
pip install python-qt5

pip install six==1.13.0
pip install wmi
pip install pyzmq

查看sip的版本,发现版本不同,前者版本较低。
解决办法:根据print(sip, sip.SIP_VERSION_STR)显示的sip位置(如/usr/lib/python2.7/dist_package)将文件夹中所有sip开头的文件删除
sudo rm -f sip*
pip install sip

新问题:the sip module implements API v12.0 to v12.6
无法解决,放弃,conda 删除vnpy20环境,重头安装

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×