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.

DJango branch: circular import problem: crontab and logging

See original GitHub issue

Describe the bug

After updating to newest django branch I no longer can launch app

Steps to reproduce

1. Run ArchiveBox e.g. ./bin/archivebox add

Screenshots or log output

Traceback (most recent call last):                                                                                                                                                                                                            
  File "/home/kangus/src/ArchiveBox/bin/archivebox", line 7, in <module>                                                                                                                                                                      
    from .cli import main                                                                                                                                                                                                                     
  File "/home/kangus/src/ArchiveBox/archivebox/cli/__init__.py", line 65, in <module>                                                                                                                                                         
    SUBCOMMANDS = list_subcommands()                                                                                                                                                                                                          
  File "/home/kangus/src/ArchiveBox/archivebox/cli/__init__.py", line 41, in list_subcommands                                                                                                                                                 
    module = import_module('.archivebox_{}'.format(subcommand), __package__)                                                                                                                                                                  
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module                                                                                                                                                                 
    return _bootstrap._gcd_import(name[level:], package, level)                                                                                                                                                                               
  File "/home/kangus/src/ArchiveBox/archivebox/cli/archivebox_init.py", line 11, in <module>                                                                                                                                                  
    from ..main import init, docstring                                                                                                                                                                                                        
  File "/home/kangus/src/ArchiveBox/archivebox/main.py", line 8, in <module>                                                                                                                                                                  
    from crontab import CronTab, CronSlices                                                                                                                                                                                                   
  File "/usr/local/lib/python3.8/dist-packages/crontab.py", line 91, in <module>                                                                                                                                                              
    import logging                                                                                                                                                                                                                            
  File "/home/kangus/src/ArchiveBox/archivebox/logging.py", line 16, in <module>                                                                                                                                                              
    from .index.schema import Link, ArchiveResult                                                                                                                                                                                             
  File "/home/kangus/src/ArchiveBox/archivebox/index/__init__.py", line 13, in <module>                                                                                                                                                       
    from ..system import atomic_write                                                                                                                                                                                                         
  File "/home/kangus/src/ArchiveBox/archivebox/system.py", line 12, in <module>                                                                                                                                                               
    from crontab import CronTab                                                                                                                                                                                                               
ImportError: cannot import name 'CronTab' from partially initialized module 'crontab' (most likely due to a circular import) (/usr/local/lib/python3.8/dist-packages/crontab.py)                                                              
Error in sys.excepthook: 
Traceback (most recent call last):                                                                                                                                                                                                    [0/6631]
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 72, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 32, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 12, in <module>
    import os, glob, subprocess, os.path, time, pwd, sys, requests_unixsocket
  File "/usr/lib/python3/dist-packages/requests_unixsocket/__init__.py", line 1, in <module>
    import requests
  File "/usr/lib/python3/dist-packages/requests/__init__.py", line 43, in <module>
    import urllib3
  File "/usr/lib/python3/dist-packages/urllib3/__init__.py", line 7, in <module>
    from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 3, in <module>
    import logging
  File "/home/kangus/src/ArchiveBox/archivebox/logging.py", line 16, in <module>
    from .index.schema import Link, ArchiveResult
  File "/home/kangus/src/ArchiveBox/archivebox/index/__init__.py", line 13, in <module>
    from ..system import atomic_write
  File "/home/kangus/src/ArchiveBox/archivebox/system.py", line 12, in <module>
    from crontab import CronTab
  File "/usr/local/lib/python3.8/dist-packages/crontab.py", line 154, in <module>
    LOG = logging.getLogger('crontab')
AttributeError: partially initialized module 'logging' has no attribute 'getLogger' (most likely due to a circular import)

Original exception was:
Traceback (most recent call last):
  File "/home/kangus/src/ArchiveBox/bin/archivebox", line 7, in <module>
    from .cli import main
  File "/home/kangus/src/ArchiveBox/archivebox/cli/__init__.py", line 65, in <module>
    SUBCOMMANDS = list_subcommands()
  File "/home/kangus/src/ArchiveBox/archivebox/cli/__init__.py", line 41, in list_subcommands
    module = import_module('.archivebox_{}'.format(subcommand), __package__)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/kangus/src/ArchiveBox/archivebox/cli/archivebox_init.py", line 11, in <module>
    from ..main import init, docstring
  File "/home/kangus/src/ArchiveBox/archivebox/main.py", line 8, in <module>
    from crontab import CronTab, CronSlices
  File "/usr/local/lib/python3.8/dist-packages/crontab.py", line 91, in <module>
    import logging
  File "/home/kangus/src/ArchiveBox/archivebox/logging.py", line 16, in <module>
    from .index.schema import Link, ArchiveResult
  File "/home/kangus/src/ArchiveBox/archivebox/index/__init__.py", line 13, in <module>
    from ..system import atomic_write
  File "/home/kangus/src/ArchiveBox/archivebox/system.py", line 12, in <module>
    from crontab import CronTab
ImportError: cannot import name 'CronTab' from partially initialized module 'crontab' (most likely due to a circular import) (/usr/local/lib/python3.8/dist-packages/crontab.py)

Software versions

  • OS: Linux Mint 20/ubuntu 20.04
  • ArchiveBox version: 848977e
  • Python version: python 3.8.2

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
terxwcommented, Jul 25, 2020

Tried latest commit, installed in venv with pip3 install -e . and no import problem!

0reactions
cdvv7788commented, Jul 22, 2020

@terxw We renamed the module to prevent the issue. Once #379 is merged, you should be able to use it as you normally do.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DJango branch: circular import problem: crontab and logging
Describe the bug After updating to newest django branch I no longer can launch app Steps to reproduce 1. Run ArchiveBox e.g. ....
Read more >
circular import caused error when i start django server
So I try to run the this project I've been working on it's a simple Django blog but when i try to start...
Read more >
Common Build Problems - Travis CI Docs
Another reason could be that the repo setting Clone or import is set to OFF. In this case, no information from the repository...
Read more >
#4731 (setup_environ assumes that settings module is called ...
I can't use management.setup_environ() for a cron script I'm using because it relies on ... into django.template.init introduces a circular import problem.
Read more >
Why is my crontab not working, and how can I troubleshoot it?
A frequent problem users make with crontab entries is that they forget that cron runs in a different environment than they do as...
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