Recursive import failing: "ImportError: cannot import name main"
See original GitHub issueThe API/api.py is importing * from astra which recursively imports API/api.py, and the logic to skip the import on iterative imports:
if os.getcwd().split('/')[-1] != 'API':
from API.api import main
isn’t working. Here’s the trace-back:
Traceback (most recent call last):
File "astra.py", line 38, in <module>
from API.api import main
File "C:\Pentest\Astra\API\api.py", line 38, in <module>
from astra import *
File "C:\Pentest\Astra\astra.py", line 38, in <module>
from API.api import main
ImportError: cannot import name main
Issue Analytics
- State:
- Created 4 years ago
- Comments:10
Top Results From Across the Web
How to Fix ImportError: Cannot Import Name in Python - Rollbar
This error generally occurs when a class cannot be imported due to one of the following reasons: The imported class is in a...
Read more >Error after upgrading pip: cannot import name 'main'
You can resolve this issue by reinstalling pip. Use one of the following command line commands to reinstall pip: Python2: python -m pip ......
Read more >How to Fix : “ImportError: Cannot import name X” in Python?
You can solve the “ ImportError : Cannot import name X” Error by resolving the circular dependencies. You can do that either by...
Read more >python-pip : ImportError: cannot import name main
I am using Debian 9.5 Stretch release. I am having import error while using pip. When I try using pip ...
Read more >How to Fix : “ImportError: Cannot import name X” in Python
In Python "ImportError: cannot import name" error generally occurs when the imported class is not accessible, or the imported class is in a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
astra.py has to be launched from directory /app/API, like this:
/app/API # python /app/astra.py --help
Commenting out line 38 in api.py works with web interface. ‘# from astra import *’