question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recursive import failing: "ImportError: cannot import name main"

See original GitHub issue

The 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:open
  • Created 4 years ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
true-herocommented, May 6, 2020

astra.py has to be launched from directory /app/API, like this: /app/API # python /app/astra.py --help

2reactions
kashazizcommented, Oct 15, 2019

Commenting out line 38 in api.py works with web interface. ‘# from astra import *’

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found