使用 Google Colab 并尝试连接到外部 API。
我已经创建了一组 SSL 证书并想部署它们,我已经安装了我的驱动器并引用了正确的文件夹,但它失败了。
import betfairlightweight
from google.colab import drive
from google.colab import files
#!pip install -U pyopenssl
drive.mount('content')
# Change this certs path to wherever you're storing your certificates
certs_path = 'content/My Drive/betfair/'
# Change these login details to your own
my_username = XXXXX
my_password = XXXXX
my_app_key = XXXXX
trading = betfairlightweight.APIClient(username=my_username,
password=my_password,
app_key=my_app_key
,certs=certs_path)
证书存在,但是当我
certs_path ='content/My Drive/betfair'
!ls certs_path
我得到了错误
ls: cannot access 'certs_path': No such file or directory
如何使用 Colab 指向我的 google 驱动器中正确的证书文件夹
最佳答案
betfairlightweight.APIClient() 调用是否失败?尝试使路径成为绝对路径:/content/My Drive/betfair/
您看到的问题与 !ls certs_path
无关。使用时! Colab 中的运算符来运行 shell 命令,你的 python 变量没有被使用。它将“certs_path”视为文本。
尝试:
!ls /content/My Drive/betfair
确保正确安装了东西。
关于python - 使用 Google Colab 的 SSL 证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57360814/