NameError: name is not defined /u/TheTechLeaf Python Education

I wrote a module that uses several of the same imports across multiple files. As a result, I created an imports.py file.

I thought I could just write from common.imports import * in each applicable file, but this creates a NameError. Here’s the information I’ve gathered so far:

  • The module in question is requests. It’s installed in both the module’s virtual environment and (in case it matters) the environment of the py file importing my module.
  • In imports.py, I tried listing it in the __all__attribute – no luck.
  • After from common.imports import * I verified whether they were listed under sys.modules, which they weren’t.
  • Importing specifically requests creates an ImportError, even with using __all__.
  • Attempting from common import imports creates an AttributeError.

Let me know if there’s anything I missed, or if I need to provide more information.

submitted by /u/TheTechLeaf
[link] [comments]

​r/learnpython I wrote a module that uses several of the same imports across multiple files. As a result, I created an imports.py file. I thought I could just write from common.imports import * in each applicable file, but this creates a NameError. Here’s the information I’ve gathered so far: The module in question is requests. It’s installed in both the module’s virtual environment and (in case it matters) the environment of the py file importing my module. In imports.py, I tried listing it in the __all__attribute – no luck. After from common.imports import * I verified whether they were listed under sys.modules, which they weren’t. Importing specifically requests creates an ImportError, even with using __all__. Attempting from common import imports creates an AttributeError. Let me know if there’s anything I missed, or if I need to provide more information. submitted by /u/TheTechLeaf [link] [comments] 

I wrote a module that uses several of the same imports across multiple files. As a result, I created an imports.py file.

I thought I could just write from common.imports import * in each applicable file, but this creates a NameError. Here’s the information I’ve gathered so far:

  • The module in question is requests. It’s installed in both the module’s virtual environment and (in case it matters) the environment of the py file importing my module.
  • In imports.py, I tried listing it in the __all__attribute – no luck.
  • After from common.imports import * I verified whether they were listed under sys.modules, which they weren’t.
  • Importing specifically requests creates an ImportError, even with using __all__.
  • Attempting from common import imports creates an AttributeError.

Let me know if there’s anything I missed, or if I need to provide more information.

submitted by /u/TheTechLeaf
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *