更新
使用pip指令进行库更新
1.开启当前环境(anaconda):在当前anaconde文件夹下打开CMD,输入conda activate ./
2.更新目标库(seaborn): pip instasll -U seaborn
3.安装pyportfolioopt库:pip install pyportfolioopt --user (加入user选项是因为文件位置可能出现WinError错误)
测试
运行指令from pypfopt.efficient_frontier import EfficientFrontier
测试通过
运行
发现scipy库被更新,导致factorial函数位置发生变化(原位置在scipy.misc),原始代码无法运行
查找原因,发现需要对scipy进行手动降低版本处理
pip install scipy==1.2 --upgrade
发现提示,pyportfolioopt库需要scipy>=1.3
发现statsmodels的版本为0.9.0将statsmodels进行升级
pip install -U statsmodels
这样statsmodels库和pyportfolioopt库就可以兼容了.
PyZMQ Issue
在代码文件运行时会报如下警告
原因是PyZMQ使用了tornado 6.x版本中的废弃函数,原文issue如下
This happens because pyzmq attempts to import a module in tornado that no longer exists (specifically, this import chunk). When it cannot find this module, it assumes tornado is not installed, tries to import a deprecated module inside pyzmq (i.e. minitornado), and triggers this warning. Tornado is of course installed—it just no longer contains this specific module—so this warning isn’t communicating the correct problem.
To fix, we either pull out the imported function from the deprecated module or stop using this function since it doesn’t exist in Tornado anymore.