Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[python] cannot import name BoolQuery from import swagger_client #8483

Closed
tarp2699 opened this issue Jul 25, 2018 · 3 comments · Fixed by #9689
Closed

[python] cannot import name BoolQuery from import swagger_client #8483

tarp2699 opened this issue Jul 25, 2018 · 3 comments · Fixed by #9689
Assignees
Milestone

Comments

@tarp2699
Copy link

Description

Hi,
I'm trying to build a python swagger client for Elastic's ECE API
A test script that imports swagger_client errors with the following.

C:\Python27\python.exe C:/bench/ece/scripts/test-connection.py
Traceback (most recent call last):
  File "C:/bench/ece/scripts/test-connection.py", line 3, in <module>
    import swagger_client
  File "build\bdist.win-amd64\egg\swagger_client\__init__.py", line 19, in <module>
    
  File "build\bdist.win-amd64\egg\swagger_client\api\__init__.py", line 6, in <module>
    
  File "build\bdist.win-amd64\egg\swagger_client\api\clusters_elasticsearch_api.py", line 21, in <module>
  File "build\bdist.win-amd64\egg\swagger_client\api_client.py", line 27, in <module>
  File "build\bdist.win-amd64\egg\swagger_client\models\__init__.py", line 32, in <module>
    
  File "build\bdist.win-amd64\egg\swagger_client\models\bool_query.py", line 19, in <module>
  File "build\bdist.win-amd64\egg\swagger_client\models\query_container.py", line 19, in <module>
ImportError: cannot import name BoolQuery
Swagger-codegen version

2.3.1

Swagger declaration file content or url

https://download.elasticsearch.org/cloud/1.1/elastic-cloud-enterprise-API-swagger.json

Command line used for generation

python
import swagger_client

Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
@greenpau
Copy link

greenpau commented Jul 27, 2019

@tarp2699 , I am seeing the same thing with tag v3.0.10.

>>> import pycherwell
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pycherwell/__init__.py", line 19, in <module>
    from pycherwell.api.business_object_api import BusinessObjectApi
  File "pycherwell/api/__init__.py", line 6, in <module>
    from pycherwell.api.business_object_api import BusinessObjectApi
  File "pycherwell/api/business_object_api.py", line 21, in <module>
    from pycherwell.api_client import ApiClient
  File "pycherwell/api_client.py", line 27, in <module>
    import pycherwell.models
  File "pycherwell/models/__init__.py", line 18, in <module>
    from pycherwell.models.action import Action
  File "pycherwell/models/action.py", line 19, in <module>
    from pycherwell.models.action import Action  # noqa: F401,E501
ImportError: cannot import name Action
>>>

The content of pycherwell/models/action.py:

# coding: utf-8

"""
    Cherwell Rest API

    Unofficial Python Cherwell REST API library.  # noqa: E501

    OpenAPI spec version: 9.3.2
    Contact: See AUTHORS.
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""


import pprint
import re  # noqa: F401

import six

from pycherwell.models.action import Action  # noqa: F401,E501

Python: 2.7.5
swagger-codegen-cli: 2.4.3-SNAPSHOT

it is likely something to do with package loader ... 🤔 💭

@ematta
Copy link

ematta commented Aug 12, 2019

I know this is old, but in case you see this use this codegen instead: https://github.com/openapitools/openapi-generator

@greenpau
Copy link

@ematta , i switched to openapi. Works well :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants