Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win10下update_bundle出错 #101

Closed
xuxiong opened this issue Apr 24, 2017 · 3 comments
Closed

win10下update_bundle出错 #101

xuxiong opened this issue Apr 24, 2017 · 3 comments

Comments

@xuxiong
Copy link

xuxiong commented Apr 24, 2017

环境为:win10,anaconda2,python3.6.1, rqalpha-2.1.2
错误输出如下:

(py36) C:\Users\xux>rqalpha update_bundle -d .rqalpha
尝试 http://7xjci3.com1.z0.glb.clouddn.com/bundles_v2/rqbundle_20170424.tar.bz2 ...
尝试 http://7xjci3.com1.z0.glb.clouddn.com/bundles_v2/rqbundle_20170423.tar.bz2 ...
尝试 http://7xjci3.com1.z0.glb.clouddn.com/bundles_v2/rqbundle_20170422.tar.bz2 ...
尝试 http://7xjci3.com1.z0.glb.clouddn.com/bundles_v2/rqbundle_20170421.tar.bz2 ...
Traceback (most recent call last):
  File "c:\anaconda2\envs\py36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\anaconda2\envs\py36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
         ��     �� {'__name__': '__main__', '__doc__': None, '__package__': '', '__loader__': <zipimporter object "C:\Anaconda2\envs\py36\Scripts\r...
         �� <code object <module> at 0x000001AC21B2AB70, file "C:\Anaconda2\envs\py36\Scripts\rqalpha.exe\__main__.py", line 2>
  File "C:\Anaconda2\envs\py36\Scripts\rqalpha.exe\__main__.py", line 9, in <module>
    sys.exit(entry_point())
    ��        �� <function entry_point at 0x000001AC21B9A158>
    �� <module 'sys' (built-in)>
  File "c:\anaconda2\envs\py36\lib\site-packages\rqalpha\__main__.py", line 66, in entry_point
    cli(obj={})
    �� <click.core.Group object at 0x000001AC2433D668>
  File "c:\anaconda2\envs\py36\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
           ��          ��       �� {'obj': {'VERBOSE': 0}}
           ��          �� ()
           �� <click.core.Group object at 0x000001AC2433D668>
  File "c:\anaconda2\envs\py36\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
         ��           �� <click.core.Context object at 0x000001AC21B610F0>
         �� <click.core.Group object at 0x000001AC2433D668>
  File "c:\anaconda2\envs\py36\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
           ��               ��                      �� <click.core.Context object at 0x000001AC2434AE10>
           ��               �� <click.core.Context object at 0x000001AC2434AE10>
           �� <function MultiCommand.invoke.<locals>._process_result at 0x000001AC219097B8>
  File "c:\anaconda2\envs\py36\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ��          ��                �� <click.core.Context object at 0x000001AC2434AE10>
           ��          �� <click.core.Command object at 0x000001AC2433DC88>
           �� <click.core.Context object at 0x000001AC2434AE10>
  File "c:\anaconda2\envs\py36\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
           ��         ��       �� {'data_bundle_path': '.rqalpha', 'locale': 'zh_Hans_CN'}
           ��         �� ()
           �� <function update_bundle at 0x000001AC24348048>
  File "c:\anaconda2\envs\py36\lib\site-packages\rqalpha\__main__.py", line 77, in update_bundle
    main.update_bundle(data_bundle_path, locale)
    ��                  ��                 �� 'zh_Hans_CN'
    ��                  �� '.rqalpha'
    �� <module 'rqalpha.main' from 'c:\\anaconda2\\envs\\py36\\lib\\site-packages\\rqalpha\\main.py'>
  File "c:\anaconda2\envs\py36\lib\site-packages\rqalpha\main.py", line 164, in update_bundle
    with click.progressbar(length=total_length, label=_(u"downloading ...")) as bar:
  File "c:\anaconda2\envs\py36\lib\site-packages\click\termui.py", line 306, in progressbar
    width=width, color=color)
  File "c:\anaconda2\envs\py36\lib\site-packages\click\_termui_impl.py", line 66, in __init__
    file = _default_text_stdout()
    ��      �� <function _make_cached_stream_func.<locals>.func at 0x000001AC21DB6F28>
    �� None
  File "c:\anaconda2\envs\py36\lib\site-packages\click\_compat.py", line 621, in func
    rv = wrapper_func()
    ��    �� <function get_text_stdout at 0x000001AC219F6048>
    �� None
  File "c:\anaconda2\envs\py36\lib\site-packages\click\_compat.py", line 385, in get_text_stdout
    rv = _get_windows_console_stream(sys.stdout, encoding, errors)
         ��                           ��           ��         �� None
         ��                           ��           �� None
         ��                           �� <module 'sys' (built-in)>
         �� <function _get_windows_console_stream at 0x000001AC21DA2488>
  File "c:\anaconda2\envs\py36\lib\site-packages\click\_winconsole.py", line 261, in _get_windows_console_stream
    func = _stream_factories.get(f.fileno())
           ��                     �� <colorama.ansitowin32.StreamWrapper object at 0x000001AC228329E8>
           �� {0: <function _get_text_stdin at 0x000001AC21D8A620>, 1: <function _get_text_stdout at 0x000001AC21DA2378>, 2: <function _get_te...
TypeError: fileno() takes 0 positional arguments but 1 was given
@wh1100717
Copy link
Member

我尝试搭建环境测试了一下,确实在Python 3.6 下会出现 如上错误,但这个应该是 click 出现了问题。具体的等我详细查看一下的....

@xuxiong
Copy link
Author

xuxiong commented Apr 25, 2017

环境调整为:win10,anaconda2,python2.7, rqalpha-2.1.2
update_bundle正常。

@wh1100717
Copy link
Member

@xuxiong 查看了一下,原因是 colorama 库更新到0.3.8版本,底层覆盖了 sys.stdout .....

其中 ansitowin32.py 文件中定义了如下内容:

class StreamWrapper(object):
    '''
    Wraps a stream (such as stdout), acting as a transparent proxy for all
    attribute access apart from method 'write()', which is delegated to our
    Converter instance.
    '''
    def __init__(self, wrapped, converter):
        # double-underscore everything to prevent clashes with names of
        # attributes on the wrapped stream object.
        self.__wrapped = wrapped
        self.__convertor = converter

    def __getattr__(self, name):
        return getattr(self.__wrapped, name)

    def write(self, text):
        self.__convertor.write(text)

    def fileno():
        raise OSError()

其中 fileno 函数 第一没实现 raise 了一个 OSError 第二 还写错了,少了个self....

从而导致 执行如下命令会报错:

import sys
sys.stdout.fileno()

而... click 包使用了 该函数....

目前 RQAlpha 指定使用 colorama==0.3.6 便可以规避该问题。

您可以指定安装 0.3.6 版本的 colorama 或者稍后更新新版本的RQAlpha 来解决该问题。

hzliu pushed a commit that referenced this issue Apr 26, 2017
shij10 pushed a commit to shij10/rqalpha that referenced this issue Apr 29, 2017
* release 2.0.0-beta

* update README

* disable register event for offline scripts

* add repr

* persist broker if need

* fix portfolio set_state

* update i18n

* add is_st_stock && is_suspended

* update i18n

* release 2.0.0

* fix broker persist

* remove duplicate option in .gitignore

* update setup.py

* add LIVE_TRADING

* do not copy; add LIVE_TRADING

* fix RunInfo

* fix dt

* 修改配置的读取方式,不再从~/.rqalpha/config.yml读取用户配置信息,而是默认从当前命令行读取config.yml,如果没有找到,则会读取系统默认配置信息。

* 1.	config 现在不再进行版本检查
2.	generate_config 现在会生成默认系统配置信息的config.yml文件
3.	不再使用config_template.yml模板

* release 2.0.1

* fix typo

* little refactory

* little fixes

* remove run_id

* use integer value for ACCOUNT_TYPE

* support context_vars with dict input

* remove debug print

* release 2.0.2

* fix mavg and vwap

* include requirements-py2.txt

* bug fixed

* release 2.0.5

* Bug Fixed: ricequant#76

* 解决 get_mod_config_path  返回值不正确的问题

* analyser benchmark bug fixed

* release 0.2.6

* fix typo

* fix de_listed

* fix AnalyserMod

* add tick event source

* implement get_ticks for test

* fix concatenate bug

* use merge sort to merge ticks

* fill open price from snapshot

* add tick price board

* get tick from event

* rename matcher & simulation broker

* remove internal limit up & limit down from bar.py

* let matcher use price board

* enable volume_limit only when frequency is 1d/1m

* update tick model

* filter past time when universe is change

* refactor

* fix limit up / limit down

* fix limit up / limit down typo

* fix typo

* fix bug when missing market data

* fix doc typo

* add match order_book_id filter

* fix before_trading

* python2 unicode compatible

* make better_exceptions unicode str compatible with python 2.7

* print time spend when performance regress

* arg_checker: fix check_are_valid_fields, is_valid_date

* fix for python2

* add count for is_suspended and is_st_stock

* fix

* fix

* fix order_percent; clear comment

* update docs

* release 2.0.7

* update version

* fix before_trading time bug

* update FAQ doc

* remove useless code

* performance tune

* add matching type check

* publish EVENT.POST_UNIVERSE_CHANGED only when universe changes really

* cache get_account_type because it is god damn slow

* update repr of snapshot

* fix before_trading time bug

* auto set default encoding with utf8

* format code

* update sys_stock_realtime readme

* add limit up & limit down

* implement a1 b1

* add data_board

* use order_book_id to be index

* fix realtime stock cause by mod conflict

* refactor event source

* remove StockRealtimePriceBoard

* add intro/optimizing_parameters

* add batch run test code

* add batch run by main.run

* add analyser batch run performance

* fix docs

* use `from rqalpha import run` to run batch

* refactor ptimizing_parameterso

* fix subscribe bug & refactor event source

* bug fixed

* release 2.0.8

* add missing logger in api

* add missing logger in api

* add  mod_sys_analyser README.rst

* update sys_analyser README

* Update README.rst

* 增加 sys_progress Mod 对应的 README.rst 文档

* 增加 sys_risk_mod 对应的README.rst

* add sys_simulation mod README.rst

* update sys_stock_realtime mod README.rst

* update docs

* update

* seems better

* preload carray

* data type matters

* update sys_funcat docs

* add more examples into sys_funcat doc

* add mod requirement

* fix format style

* update rqalpha_mod_sys_analyser docs

* update docs

* update docs

* add optimizing parameters examples in docs

* unify is_suspended/is_st_stock

* add set_pending_cancel

* fix logic bug in order.is_final

* refactor deal_price_decider create

* format test code

* format example code

* fix test_api_base

* refactor test_api

* remove test code

* show progress bar for test_api

* fix typo

* fix test_api_future/test_api_stock

* fix doc

* fix test code

* update simulation broker

* use env.get_instrument instead of data_proxy

* update signal broker

* bug fixed

* update sys analyser mod

* format code

* update history_bars api

* add signal test algo

* disable test_api temporarily

* fix rqalpha cmd error

* format code

* update i18n

* release 2.0.9

* add error message, fix bug in test cases

* fix only export custom user mod config issue

* Update signal_broker.py

81行修改了一处BUG

* format code

* update docs

* Develop (ricequant#89)

* test

* test

* merge 2.0.6

* commit

* commit

* fix no settlement

* delete tags

* add extend_api example

* update docs

* update docs

* release 2.1.0

* release 2.1.0

* update docs

* 提供 `from rqalpha import cli` 方便第三方 Mod 扩展 `rqalpha` command

* add include_now

* fix data_proxy

* Fix ricequant#90

* fix concept testcase

* do not create position until first trade

* add quarter arg checker

* fix include_now in BEFORE_TRADING

* refactor

refactor rqalpha_mod_sys_funcat

* fix bar_count

* refactor get_price

remove useless code

* refactor sys_funcat

* Fix bug issue#94

* release 2.1.2

* add bar count scale

* don't create position

* add stock & future test case

* refactor test.py

* fix travis in 2.7 because ipython==6.0+ is not support python 2

* fix bug when running future

* fix alpha calculate error

* update test pkl

* update i18n

* require six

* only futures has settle price

* use int32/int64

* fix transaction_cost

* fix typo

* add pnl/starting_cash/fronzen_cash

* fix frozen_cash

* add requests lib requirement

* update translation

* fix tiny bug for rqalpha mod install cmd

* fix history_bars

* make price_limit as a warning switcher option for signal model

* fix history_bars when include_now=True

* remove force include_now=False

* fix history_bars

* fix regression

* support config.json as user config file

* bug fixed

* add issue template

* Update issue_template.md

* add comment

* bug fixed

* fix future calc

* fix ricequant#101

* release 2.1.3

* update version

* update pkl

* remove unused typing lib

* add deprecated property for making old version RQA compatible

* fix plot when only backtest with one day

* fix settlement price

* fix history_bars because we misuse ExecutionContext.phase()

* 增加期货账户级别仓位强平 ricequant#108

* pass test case

* update i18n

* release 2.1.4

* bug fixed

* fix frozen_cash cal

* fix clear position
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants