【发布时间】:2019-04-12 17:58:24
【问题描述】:
我正在尝试在 Flask 项目中使用 Stava API。看过以下stackoverflow
并安装了 swagger_client
swagger-codegen generate -i https://developers.strava.com/swagger/swagger.json -l python -o ./StravaPythonClient
按照他们的指示。但是,当我运行该应用程序时,我仍然得到import swagger_client
ModuleNotFoundError: No module named 'swagger_client'
我的代码在这里
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint
# Configure OAuth2 access token for authorization: strava_oauth
swagger_client.configuration.access_token = 'fe931c21b503a46b61b1000000000000000000000'
# create an instance of the API class
api_instance = swagger_client.StreamsApi()
id = 2284367626 # Long | The identifier of the activity.
#keys = # array[String] | Desired stream types.
keyByType = true # Boolean | Must be true. (default to true)
try:
# Get Activity Streams
api_response = api_instance.getActivityStreams(id, keys, keyByType)
pprint(api_response)
except ApiException as e:
print("Exception when calling StreamsApi->getActivityStreams: %s\n" % e)
不确定我现在应该安装哪些软件包才能使其正常工作。
【问题讨论】:
-
你的问题是什么?
-
对不起...我如何安装 swagger_client
-
您使用什么版本的 Swagger Codegen?检查
swagger-codegen version。 -
swagger-codegen version 07:49:27.261 [main] DEBUG io.swagger.codegen.v3.cli.SwaggerCodegen - there are not options for command 'langs' 07:49:27.263 [main] DEBUG io.swagger.codegen.v3.cli.SwaggerCodegen - there are not options for command 'version' 3.0.5我相信3.0.5