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.

Bugfix: can't use Python API

See original GitHub issue

Describe the bug

Importing the python API fails: ImportError: cannot import name 'update' from partially initialized module 'archivebox.main' (most likely due to a circular import)

Steps to reproduce

  1. pip install archivebox
  2. python -c "from archivebox.main import add"

Screenshots or log output

Python 3.8.5 (default, Aug 12 2020, 00:00:00) 
[GCC 10.2.1 20200723 (Red Hat 10.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from archivebox.main import add, remove, info, config
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/projects/news/ArchiveBox/archivebox/main.py", line 10, in <module>
    from .cli import (
  File "/home/user/projects/news/ArchiveBox/archivebox/cli/__init__.py", line 65, in <module>
    SUBCOMMANDS = list_subcommands()
  File "/home/user/projects/news/ArchiveBox/archivebox/cli/__init__.py", line 41, in list_subcommands
    module = import_module('.archivebox_{}'.format(subcommand), __package__)
  File "/home/user/.virtualenvs/archivebox/lib64/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/user/projects/news/ArchiveBox/archivebox/cli/archivebox_update.py", line 11, in <module>
    from ..main import update
ImportError: cannot import name 'update' from partially initialized module 'archivebox.main' (most likely due to a circular import) (/home/user/projects/news/ArchiveBox/archivebox/main.py)

Software versions

  • OS: fedora-32
  • ArchiveBox version: v0.4.21 (from pip: c1f2188 I suppose)
  • Python version: 3.8.5
  • Chrome version: (not relevant)

Additional Notes

Seems to be similar to https://github.com/pirate/ArchiveBox/issues/372

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
piratecommented, Apr 6, 2021

I believe all the issues reported here have been fixed at this point e92db03, but feel free to comment back here if you’re still having problems and I’ll open the ticket.

>>> from archivebox.config import setup_django
>>> setup_django()
...
>>> from main import init
>>> init()
...
>>> from core.models import Snapshot
>>> Snapshot.objects.all()
<QuerySet []>
1reaction
piratecommented, Sep 30, 2020

We don’t currently support running it from another directory other than the data dir, the os.chdir(DATA_DIR) call (before setup_django()) is mandatory for now. This restriction will likely be lifted in a future version once archivebox oneshot is released.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Should You Update to the Latest Python Bugfix Version?
Bugfix releases will only contain bug and security fixes. You most likely won't experience any difference between two versions of the same ...
Read more >
Int/str conversions broken in latest Python bugfix releases
The latest bugfix releases of all supported Python versions break printing or parsing large integers e.g.: >>> import math ...
Read more >
Int/str conversions broken in latest Python bugfix releases
It's disappointing that the core Python team has pushed out breaking (supposedly “bugfix”) releases for all supported versions with no notice ...
Read more >
Int/str conversions broken in latest Python bugfix releases
Octal, hexadecimal, and int from/to bytes conversions are not limited because they have linear complexity.
Read more >
Int/str conversions broken in latest Python bugfix releases
API breakage: I expect that limiting str(integer) will cause more existing programs to break than limiting int(text) . This is because existing ...
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