ImportError:在Mac上没有名为cryptography.hazmat.backends的模块 - boxsdk

Gar*_*han 11 python macos openssl cryptography

我目前正在尝试从我的Python自动化中自动将单个文件(现在)上传到Box.

我正在使用Box开发者网站上的代码,该代码应该是"超级易用"但当我尝试运行此页面上的简单程序时,我收到错误(请参阅上面的标题):https:// www.box.com/blog/introducing-box-python-sdk/.我添加了我的客户端ID,客户端密码和开发人员令牌,并添加了我的zip文件上传路径,并不断收到上述错误.除此之外,我没有改变任何事情.

那些不想点击链接的人的代码:)

from boxsdk import Client, OAuth2

oauth = OAuth2(
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
    access_token="YOUR_DEVELOPER_TOKEN",
)

client = Client(oauth)
shared_folder = client.folder(
    folder_id='0',
).create_subfolder('shared_folder')

uploaded_file = shared_folder.upload('/path/to/file')
shared_link = shared_folder.get_shared_link()
Run Code Online (Sandbox Code Playgroud)

我已经使用pip和easy_install安装了加密程序,以及libffi和openssl以及oauth2只是为了安全而且没有任何作用.谁能帮我?

谢谢,加里

ohe*_*ohe 14

这个错误与boxsdk库无关,但有一个依赖:cryptography.

大多数情况下,它发生是因为cryptography库安装失败.大多数情况下,它失败了,因为默认情况下大多数计算机上都没有安装libffi.

如果你正在使用brew,只需进入你的终端并输入即可 brew install libffi

然后重新安装cryptographyboxsdk使用pip:

pip install cryptography --force-reinstall


小智 8

试试吧.祝好运!

rm -rf /usr/local/lib/python2.7/dist-packages/fabric/fabric-home-assistant

sudo apt-get install libffi-dev libssl-dev

sudo pip install cryptography --force-reinstall
Run Code Online (Sandbox Code Playgroud)