如何在PyScript中从GitHub仓库安装并导入模块?
在PyScript中从GitHub仓库导入tvDatafeed模块
要在PyScript中使用来自GitHub的tvDatafeed模块,你需要通过py-env块声明该依赖,替代传统的pip命令。具体实现步骤如下:
1. 声明GitHub依赖
在PyScript代码开头的py-env块中,按格式指定GitHub仓库地址:
<py-env> - tvdatafeed @ git+https://github.com/StreamAlpha/tvdatafeed.git </py-env>
2. 编写使用代码
完成依赖声明后,就可以正常导入并使用模块了:
from tvDatafeed import TvDatafeed, Interval # 替换为你的TradingView账号信息 username = 'YourTradingViewUsername' password = 'YourTradingViewPassword' tv = TvDatafeed(username, password)
说明
PyScript的py-env支持直接通过@ git+仓库地址的方式安装GitHub上的Python包,效果等价于你提供的pip命令pip install --upgrade --no-cache-dir git+https://github.com/StreamAlpha/tvdatafeed.git。
内容的提问来源于stack exchange,提问作者Bestshare IN
相关产品推荐
相关产品推荐

