ricequant / rqalpha

A extendable, replaceable Python algorithmic backtest && trading framework supporting multiple securities
http://rqalpha.io
Other
5.39k stars 1.62k forks source link

pip show & pip uninstall error in version 3.1.1 on windows #369

Closed BurdenBear closed 6 years ago

BurdenBear commented 6 years ago

RQAlpha的版本: 3.1.1 Python的版本:3.6.6 pip 版本:18.0 系统版本Window10-64位

安装后 pip show 或者pip uninstall rqalpha 出现:

$pip show rqalpha
Exception:
Traceback (most recent call last):
  File "D:\Anaconda3\envs\rqalpha\lib\site-packages\pip\_internal\basecommand.py", line 141, in main
    status = self.run(options, args)
  File "D:\Anaconda3\envs\rqalpha\lib\site-packages\pip\_internal\commands\show.py", line 47, in run
    results, list_files=options.files, verbose=options.verbose):
  File "D:\Anaconda3\envs\rqalpha\lib\site-packages\pip\_internal\commands\show.py", line 130, in print_results
    for i, dist in enumerate(distributions):
  File "D:\Anaconda3\envs\rqalpha\lib\site-packages\pip\_internal\commands\show.py", line 77, in search_packages_info
    lines = dist.get_metadata_lines('RECORD')
  File "D:\Anaconda3\envs\rqalpha\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 1409, in get_metadata_lines
    return yield_lines(self.get_metadata(name))
  File "D:\Anaconda3\envs\rqalpha\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 1405, in get_metadata
    raise e
  File "D:\Anaconda3\envs\rqalpha\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 1402, in get_metadata
    return value.decode('utf-8') if six.PY3 else value
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb4 in position 39880: invalid start byte

可能导致的问题,之后的版本升级可能由于卸载之前版本失败而导致升级事务失败。

原因大概是windows上文件路径用的gbk编码,pip show和uninstall中间有一步会去读出rqalpha-3.1.1.dist-info中的一个RECORD文件(里面放了所有module相关文件的路径)然后尝试用"utf-8"解码,然后上传到pypi的时候dist-info文件夹下有文件路径中有中文(mac下打包好拷到windows下上传pypi的?),导致编码不一致。大概换台机器重新打包传一次pypi就好了 image 附: rqalpha-3.1.1.dist-info/RECORD 467行

...
rqalpha/__pycache__/main.cpython-36.pyc,,
rqalpha/__pycache__/user_module.cpython-36.pyc,,
rqalpha/__pycache__/__init__.cpython-36.pyc,,
rqalpha/__pycache__/__main__.cpython-36.pyc,,
rqalpha-3.1.1.dist-info/PKG-INFO-��������MacBook Pro,,
tests/api/__pycache__/test_api_base.cpython-36.pyc,,
tests/api/__pycache__/test_api_future.cpython-36.pyc,,
tests/api/__pycache__/test_api_stock.cpython-36.pyc,,
...
BurdenBear commented 6 years ago

临时解决方案: 手动删除原来的site-packages中的rqlalpha和rqalpha-3.1.1.dist-info 然后直接以源码的方式安装

pip install git+https://github.com/ricequant/rqalpha.git@release/3.1.1
Cuizi7 commented 6 years ago

多谢提醒,现已删除异常文件并重新上传为3.1.2版本。