Skip to content

Setting up development environment results in circular import errors  #350

Closed

Description

@vaskokj

Bug/Issue Description:
Get circular import errors below when trying to run main.py to modify code and to debug in IDE.

ImportError: cannot import name 'ndarray' from partially initialized module 'numpy' (most likely due to a circular import) (./DVR-Scan/venv/lib/python3.8/site-packages/numpy/__init__.py)

Required Information:
git clone https://github.com/Breakthrough/DVR-Scan.git
python3 -m build

This builds successfully and produces the dvr-scan files however when I try to run the code directly so I can attach a debugger I get the following errors.

source venv/bin/activate
pip install -r requirements.txt
PYTHONPATH=. python dvr_scan/__main__.py

Produces error

ImportError: cannot import name 'ndarray' from partially initialized module 'numpy' (most likely due to a circular import) (./DVR-Scan/venv/lib/python3.8/site-packages/numpy/__init__.py)

Same thing happens in VSCode and PyCharm

Expected Behavior:
Execution of dvr-scan.

Computing Environment:

  • OS: [e.g. Windows, Linux (Distro: Ubuntu, Mint, Fedora, etc...), OSX]: Linux Ubuntu 20.04
  • Python Version: [e.g. 3.6 or 3.6.6]: 3.8
  • OpenCV Version: [e.g. 3.4.1]
pip list installed
Package               Version 
--------------------- --------
appdirs               1.4.4   
attrs                 22.1.0  
build                 0.9.0   
click                 8.1.3   
exceptiongroup        1.0.0   
iniconfig             1.1.1   
numpy                 1.23.4  
opencv-contrib-python 4.6.0.66
opencv-python         4.6.0.66
packaging             21.3    
pep517                0.13.0  
pip                   20.0.2  
pkg-resources         0.0.0   
platformdirs          2.5.2   
pluggy                1.0.0   
pyparsing             3.0.9   
pytest                7.2.0   
scenedetect           0.6.0.3 
screeninfo            0.8.1   
setuptools            44.0.0  
tomli                 2.0.1   
tqdm                  4.64.1

I could have missed some instructions but only found a little snipped on the "Downloads" page on setting up a development environment.

https://dvr-scan.readthedocs.io/en/latest/download/

To install from source, download and extract the latest release to a location of your choice, and make sure you have the appropriate system requirements installed before continuing. DVR-Scan can be built by running the following command:

python -m build

Activity

  1. Breakthrough commented on Sep 18, 2023

    @Breakthrough
    Owner

    This might be coming from scenedetect which is another project I maintain - that's the only dependency here which seems to import only one item from numpy. All uses with in DVR-Scan import the entire module. Can you confirm if this happens with the latest version of Numpy?

    Thanks!

  2. added this to the v0.6.3 milestone on Sep 18, 2023
  3. Breakthrough commented on Dec 2, 2023

    @Breakthrough
    Owner

    This should be fixed in the next release, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions