Reputation: 4083
I have installed a couple of dependencies in editable state using pip install -e path/to/project
, using the command parameter -e
for the first time today.
For the first dependency, the project sort
, everything worked perfectly.
But for the other dependency, the project yolov3
things didn't work out as fine, although I have used the same exact commands:
To installation
(torch) user@user-PC:~/Code/Project$ pip install -e Detection/yolov3/
To check
(torch) user@user-PC:~/Code/Project$ pip show yolov3
Name: yolov3
Version: 1.0
Summary: UNKNOWN
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Location: /home/user/Code/Project/Detection/yolov3
Requires:
Required-by:
To use
from sort import Sort
from yolov3 import get_detections_from_single_frame as get_detections
dummy_frame = None
mot_tracker = Sort()
track_bbs_ids = mot_tracker.update(get_detections(dummy_frame))
But I get an error as
(torch) user@user-PC:~/Code/Project$ python main.py
Traceback (most recent call last):
File "main.py", line 10, in <module>
from yolov3 import get_detections_from_single_frame as get_detections
ModuleNotFoundError: No module named 'yolov3'
I have tried to change the name to yolo to eliminate the number in the module name and it did not work, but I might have failed to change the project name itself.
Here is the setup.py that I am using for the project yolov3 (I am using the same for sort, except for the name property for obvious reasons):
from setuptools import setup, find_packages
setup(name='yolov3', version='1.0', packages=find_packages())
Here is the project structure:
yolov3/
├── __init__.py
├── models/
| ├── __init__.py
| ├── liba1.py
| ├── liba2.py
| ├── liba3.py
├── utils/
| ├── __init__.py
| ├── libb1.py
| ├── libb2.py
| ├── libb3.py
└── weights/
└── libc1.py
Could someone please tell me what am I missing?
PS:
Following Haller Patrick's advice, modifying the project structure eliminated the original error message.
yolov3/
├── yolov3/
| ├── __init__.py
| ├── models/
| | ├── __init__.py
| | ├── liba1.py
| | ├── liba2.py
| | ├── liba3.py
| ├── utils/
| | ├── __init__.py
| | ├── libb1.py
| | ├── libb2.py
| | ├── libb3.py
| └── weights/
| └── libc1.py
|
└── setup.py
But a message in a deeper folder level appeared:
Traceback (most recent call last):
File "/home/user/Code/Project/main.py", line 10, in <module>
from yolov3.detect import get_detections_from_single_frame as get_detections
File "/home/user/Code/Project/Detection/yolov3/yolov3/detect.py", line 9, in <module>
from models.experimental import attempt_load
ModuleNotFoundError: No module named 'models'
Upvotes: 0
Views: 444
Reputation: 113
For a precise answer, you would have to provide the project structure of the package yolov3
. But I guess the problem is that the package yolov3
, does not include a module to build.
A minimal project structure has to look like this:
yolov3/
├── yolov3/
│ ├── __init__.py
│ ├── lib1.py
│ ├── ...
│ └── ...
├── setup.py
Important is the __init__.py
file, so yolov3
can be imported as a module. This worked for me.
For reference, here is a python package which uses this structure: https://github.com/gruns/icecream
Upvotes: 1