FutunnOpen / py-futu-api

富途 OpenAPI Python SDK
Apache License 2.0
1.04k stars 221 forks source link

RSA key is invalid #83

Closed HarryChiu closed 3 years ago

HarryChiu commented 3 years ago

环境: Python 3.8 futu-api 5.1.1320 FutuOpenD 5.1.1320 (Ubuntu version)

重现过程: 在FutuOpenD.xml中配置RSA: private_key_path 服务启动正常 提示RSA已启用 Python中按照文档配置: SysConfig.enable_proto_encrypt(True) SysConfig.set_init_rsa_file("private_key_path") 报错如下: on_connected:357: InitConnect.pack_req fail: msg=module 'time' has no attribute 'clock'; (-1, 'RSA key is invalid')

尝试了官方示例中的Key 也同样报错

loadatom commented 3 years ago

打印下以下代码的结果:

import time
print(dir(time))
HarryChiu commented 3 years ago

['CLOCK_MONOTONIC', 'CLOCK_MONOTONIC_RAW', 'CLOCK_PROCESS_CPUTIME_ID', 'CLOCK_REALTIME', 'CLOCK_THREAD_CPUTIME_ID', '_STRUCT_TM_ITEMS', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'altzone', 'asctime', 'clock_getres', 'clock_gettime', 'clock_gettime_ns', 'clock_settime', 'clock_settime_ns', 'ctime', 'daylight', 'get_clock_info', 'gmtime', 'localtime', 'mktime', 'monotonic', 'monotonic_ns', 'perf_counter', 'perf_counter_ns', 'process_time', 'process_time_ns', 'pthread_getcpuclockid', 'sleep', 'strftime', 'strptime', 'struct_time', 'thread_time', 'thread_time_ns', 'time', 'time_ns', 'timezone', 'tzname', 'tzset']

HarryChiu commented 3 years ago

Python 3.7/3.6 正常 Python 3.8 报如上错误

loadatom commented 3 years ago

再看下依赖库的版本..

your_python38 -m pip show PyCryptodome simplejson pandas protobuf

HarryChiu commented 3 years ago

Name: pycryptodome Version: 3.4.3 Summary: Cryptographic library for Python Home-page: http://www.pycryptodome.org Author: Helder Eijs Author-email: helderijs@gmail.com License: UNKNOWN Location: /home/harry/anaconda3/lib/python3.8/site-packages Requires: Required-by: futu-api

Name: simplejson Version: 3.17.2 Summary: Simple, fast, extensible JSON encoder/decoder for Python Home-page: https://github.com/simplejson/simplejson Author: Bob Ippolito Author-email: bob@redivi.com License: MIT License Location: /home/harry/anaconda3/lib/python3.8/site-packages Requires: Required-by: futu-api

Name: pandas Version: 0.25.3 Summary: Powerful data structures for data analysis, time series, and statistics Home-page: http://pandas.pydata.org Author: None Author-email: None License: BSD Location: /home/harry/anaconda3/lib/python3.8/site-packages Requires: pytz, python-dateutil, numpy Required-by: yfinance, statsmodels, seaborn, jqdatasdk, futu-api

Name: protobuf Version: 3.5.1 Summary: Protocol Buffers Home-page: https://developers.google.com/protocol-buffers/ Author: protobuf@googlegroups.com Author-email: protobuf@googlegroups.com License: 3-Clause BSD License Location: /home/harry/anaconda3/lib/python3.8/site-packages Requires: setuptools, six Required-by: futu-api

loadatom commented 3 years ago

升级下pycryptodome试试吧,可能是这个问题

HarryChiu commented 3 years ago

这四个都升级后 貌似解决了 感谢~