因为想在Windows机器上复现一个项目,报错:
no module named ‘_jsonnet’
网上搜索一番发现是需要jsonnet的包。然后尝试无论pip, conda, 还是直接下载.whl文件都无法成功安装。似乎原因是Windows不兼容这个包。
最后发现以下方式成功运行项目:
- 下载jsonnet-binary而不是jsonnet :
pip install jsonnet_binary
- 测试是否成功:
import _jsonnet
# Define a Jsonnet snippet
jsonnet_str = '''
{
person1: {
name: "Alice",
welcome: "Hello " + self.name + "!",
},
person2: {
name: "Bob",
welcome: "Hello " + self.name + "!",
},
}
'''
# Evaluate the Jsonnet snippet to JSON
result = _jsonnet.evaluate_snippet("snippet", jsonnet_str)
print(result)
芜湖搞定!