manchenkoff / openapi3-parser

OpenAPI 3 parser to use a specification inside of the code in your projects
https://pypi.org/project/openapi3-parser/
MIT License
65 stars 34 forks source link

Parse method (basic example) not work #24

Closed francescobianca closed 2 years ago

francescobianca commented 2 years ago

First:

pip install openapi3-parser

Now:

from openapi_parser import parse

ImportError: cannot import name 'parse' from 'openapi_parser' (unknown location)

Python Version: 3.8 System: Ubuntu 20.04.3 LTS

MichielBontenbal commented 2 years ago

from openapi_parser import parse

TypeError: 'type' object is not subscriptable

Jupyter 6.4.5 Windows 11

manchenkoff commented 2 years ago

Hi @francescobianca @MichielBbal, please note that current package requires Python 3.9 as you can see here, some changes are backward incompatible, please try with newer version, if it doesn't work, feel free to tag me again

Anurag-Pola commented 2 years ago

My python version is 3.9.13, am still getting the ImportError, Am I missing something? @manchenkoff

manchenkoff commented 2 years ago

@Anurag-Pola, I've just checked on your version, seems fine

Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from openapi_parser import parse
>>> help(parse)
Help on function parse in module openapi_parser.parser:

parse(uri: str) -> openapi_parser.specification.Specification
    Parse specification document by URL or filepath

    Args:
        uri (str): Path or URL to OpenAPI file

>>>

Please, check your version again or attach more details (like the output I pasted above)

Anurag-Pola commented 2 years ago

Hey @manchenkoff , Thank You for the quick response and sorry for the delay in mine.

I tried the same but got the following error!

Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from openapi_parser import parse
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'parse' from 'openapi_parser' (unknown location)
manchenkoff commented 2 years ago

@Anurag-Pola it's so weird, unfortunately I don't have any useful thing to solve it and it seems that problem is not in the package. This error usually occurs when there is no object with given name, but it's definitely there.

Just out of curiosity, have you tried to install the package in virtualenv or pipenv?

Anurag-Pola commented 2 years ago

I tried it out in pipenv and normal environment

manchenkoff commented 2 years ago

@Anurag-Pola sad to hear that 😞 can you try to install 0.0.9 package version because later versions were updated to Python 3.9? If problem persists, I suggest reinstalling of python