Search code examples
pythontensorflowdarkflow

Darkflow -- No module named 'darkflow.cython_utils.cy_yolo_findboxes'


I've succesfully installed darkflow-1.0.0 (https://github.com/thtrieu/darkflow) on the Windows 10 using the pip install . command.

Successfully built darkflow
Installing collected packages: darkflow
  Found existing installation: darkflow 1.0.0
    Uninstalling darkflow-1.0.0:
      Successfully uninstalled darkflow-1.0.0
Successfully installed darkflow-1.0.0

After this, I'm trying to run python flow --h, which gives me following error:

Traceback (most recent call last):
  File "flow", line 4, in <module>
    from darkflow.cli import cliHandler
  File "C:\Users\filda\Desktop\FIT_VUT\BP\YOLO\YOLO_keras\darkflow\darkflow\cli.py", line 3, in <module>
    from .net.build import TFNet
  File "C:\Users\filda\Desktop\FIT_VUT\BP\YOLO\YOLO_keras\darkflow\darkflow\net\build.py", line 7, in <module>
    from .framework import create_framework
  File "C:\Users\filda\Desktop\FIT_VUT\BP\YOLO\YOLO_keras\darkflow\darkflow\net\framework.py", line 1, in <module>
    from . import yolo
  File "C:\Users\filda\Desktop\FIT_VUT\BP\YOLO\YOLO_keras\darkflow\darkflow\net\yolo\__init__.py", line 2, in <module>
    from . import predict
  File "C:\Users\filda\Desktop\FIT_VUT\BP\YOLO\YOLO_keras\darkflow\darkflow\net\yolo\predict.py", line 7, in <module>
    from ...cython_utils.cy_yolo_findboxes import yolo_box_constructor
ModuleNotFoundError: No module named 'darkflow.cython_utils.cy_yolo_findboxes'

So i tried to build the Cython extensions using the python setup.py build_ext --inplace command, which gives me the following error:

(base) C:\Users\filda\Desktop\FIT_VUT\BP\YOLO\YOLO_keras\darkflow-master>python setup.py build_ext --inplace
running build_ext
building 'darkflow.cython_utils.nms' extension
creating build\temp.win-amd64-3.5
creating build\temp.win-amd64-3.5\Release
creating build\temp.win-amd64-3.5\Release\darkflow
creating build\temp.win-amd64-3.5\Release\darkflow\cython_utils
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\HostX64\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -IC:\Users\filda\Anaconda3\lib\site-packages\numpy\core\include -IC:\Users\filda\Anaconda3\include -IC:\Users\filda\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\Include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\ATLMFC\Include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" /Tcdarkflow/cython_utils/nms.c /Fobuild\temp.win-amd64-3.5\Release\darkflow/cython_utils/nms.obj
nms.c
c1: fatal error C1083: Cannot open source file: 'darkflow/cython_utils/nms.c': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.15.26726\\bin\\HostX64\\x64\\cl.exe' failed with exit status 2

pip show -f darkflow:

Name: darkflow
Version: 1.0.0
Summary: Darkflow
Home-page: https://github.com/thtrieu/darkflow
Author: UNKNOWN
Author-email: UNKNOWN
License: GPLv3
Location: c:\users\filda\anaconda3\lib\site-packages
Requires:
Required-by:
Files:
  ..\..\Scripts\flow
  darkflow-1.0.0.dist-info\INSTALLER
  darkflow-1.0.0.dist-info\METADATA
  darkflow-1.0.0.dist-info\RECORD
  darkflow-1.0.0.dist-info\WHEEL
  darkflow-1.0.0.dist-info\top_level.txt
  darkflow\__init__.py
  darkflow\__pycache__\__init__.cpython-35.pyc
  darkflow\__pycache__\cli.cpython-35.pyc
  darkflow\__pycache__\defaults.cpython-35.pyc
  darkflow\__pycache__\version.cpython-35.pyc
  darkflow\cli.py
  darkflow\cython_utils\__init__.py
  darkflow\cython_utils\__pycache__\__init__.cpython-35.pyc
  darkflow\cython_utils\cy_yolo2_findboxes.cp35-win_amd64.pyd
  darkflow\cython_utils\cy_yolo_findboxes.cp35-win_amd64.pyd
  darkflow\cython_utils\nms.cp35-win_amd64.pyd
  darkflow\dark\__init__.py
  darkflow\dark\__pycache__\__init__.cpython-35.pyc
  darkflow\dark\__pycache__\connected.cpython-35.pyc
  darkflow\dark\__pycache__\convolution.cpython-35.pyc
  darkflow\dark\__pycache__\darknet.cpython-35.pyc
  darkflow\dark\__pycache__\darkop.cpython-35.pyc
  darkflow\dark\__pycache__\layer.cpython-35.pyc
  darkflow\dark\connected.py
  darkflow\dark\convolution.py
  darkflow\dark\darknet.py
  darkflow\dark\darkop.py
  darkflow\dark\layer.py
  darkflow\defaults.py
  darkflow\net\__init__.py
  darkflow\net\__pycache__\__init__.cpython-35.pyc
  darkflow\net\__pycache__\build.cpython-35.pyc
  darkflow\net\__pycache__\flow.cpython-35.pyc
  darkflow\net\__pycache__\framework.cpython-35.pyc
  darkflow\net\__pycache__\help.cpython-35.pyc
  darkflow\net\build.py
  darkflow\net\flow.py
  darkflow\net\framework.py
  darkflow\net\help.py
  darkflow\net\ops\__init__.py
  darkflow\net\ops\__pycache__\__init__.cpython-35.pyc
  darkflow\net\ops\__pycache__\baseop.cpython-35.pyc
  darkflow\net\ops\__pycache__\convolution.cpython-35.pyc
  darkflow\net\ops\__pycache__\simple.cpython-35.pyc
  darkflow\net\ops\baseop.py
  darkflow\net\ops\convolution.py
  darkflow\net\ops\simple.py
  darkflow\net\vanilla\__init__.py
  darkflow\net\vanilla\__pycache__\__init__.cpython-35.pyc
  darkflow\net\vanilla\__pycache__\train.cpython-35.pyc
  darkflow\net\vanilla\train.py
  darkflow\net\yolo\__init__.py
  darkflow\net\yolo\__pycache__\__init__.cpython-35.pyc
  darkflow\net\yolo\__pycache__\data.cpython-35.pyc
  darkflow\net\yolo\__pycache__\misc.cpython-35.pyc
  darkflow\net\yolo\__pycache__\predict.cpython-35.pyc
  darkflow\net\yolo\__pycache__\train.cpython-35.pyc
  darkflow\net\yolo\data.py
  darkflow\net\yolo\misc.py
  darkflow\net\yolo\predict.py
  darkflow\net\yolo\train.py
  darkflow\net\yolov2\__init__.py
  darkflow\net\yolov2\__pycache__\__init__.cpython-35.pyc
  darkflow\net\yolov2\__pycache__\data.cpython-35.pyc
  darkflow\net\yolov2\__pycache__\predict.cpython-35.pyc
  darkflow\net\yolov2\__pycache__\train.cpython-35.pyc
  darkflow\net\yolov2\data.py
  darkflow\net\yolov2\predict.py
  darkflow\net\yolov2\train.py
  darkflow\utils\__init__.py
  darkflow\utils\__pycache__\__init__.cpython-35.pyc
  darkflow\utils\__pycache__\box.cpython-35.pyc
  darkflow\utils\__pycache__\im_transform.cpython-35.pyc
  darkflow\utils\__pycache__\loader.cpython-35.pyc
  darkflow\utils\__pycache__\pascal_voc_clean_xml.cpython-35.pyc
  darkflow\utils\__pycache__\process.cpython-35.pyc
  darkflow\utils\box.py
  darkflow\utils\im_transform.py
  darkflow\utils\loader.py
  darkflow\utils\pascal_voc_clean_xml.py
  darkflow\utils\process.py
  darkflow\version.py

I have made it working on linux, but still i would appreciate it working on windows as well. May somebode point me to right direction ?


Solution

  • This is a name clash: you have successfully installed the package via pip install ., so now darkflow is available in sys.path via site-packages directory. However, when you run python script.py, the current working directory is prepended to sys.path, so if the current dir contains the package darkflow, it is selected before the one installed in site-packages. Since the source code directory doesn't contain the shared object, the script fails.

    Solution is either to run the script from another directory, e.g.

    cd %HOMEPATH% & flow -h
    

    or, if you need to work with the code, reinstall the package in editable mode:

    pip uninstall -y darkflow & cd path\to\darkflow-master & pip install -e .
    

    This way, the shared objects will be compiled and placed along with the source code, so you can run flow from anywhere now.