Bug fix in installing and lauching the program
This commit is contained in:
236
INSTALL_TEST.md
Normal file
236
INSTALL_TEST.md
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
# Installation Testing Guide
|
||||||
|
|
||||||
|
This guide helps you verify that the package installation works correctly.
|
||||||
|
|
||||||
|
## Clean Installation Test
|
||||||
|
|
||||||
|
### 1. Remove Any Previous Installations
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Deactivate any active virtual environment
|
||||||
|
deactivate
|
||||||
|
|
||||||
|
# Remove old virtual environment (if exists)
|
||||||
|
rm -rf venv
|
||||||
|
|
||||||
|
# Create fresh virtual environment
|
||||||
|
python3 -m venv venv
|
||||||
|
source venv/bin/activate # On Linux/Mac
|
||||||
|
# or
|
||||||
|
venv\Scripts\activate # On Windows
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Install the Package
|
||||||
|
|
||||||
|
#### Option A: Editable/Development Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -e .
|
||||||
|
```
|
||||||
|
|
||||||
|
This allows you to modify source code and see changes immediately.
|
||||||
|
|
||||||
|
#### Option B: Regular Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install .
|
||||||
|
```
|
||||||
|
|
||||||
|
This installs the package as if it were from PyPI.
|
||||||
|
|
||||||
|
### 3. Verify Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Check package is installed
|
||||||
|
pip list | grep microscopy
|
||||||
|
|
||||||
|
# Check version
|
||||||
|
microscopy-detect --version
|
||||||
|
# Expected output: microscopy-object-detection 1.0.0
|
||||||
|
|
||||||
|
# Test Python import
|
||||||
|
python -c "import src; print(src.__version__)"
|
||||||
|
# Expected output: 1.0.0
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Test Entry Points
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Test CLI
|
||||||
|
microscopy-detect --help
|
||||||
|
|
||||||
|
# Test GUI launcher (will open window)
|
||||||
|
microscopy-detect-gui
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. Verify Package Contents
|
||||||
|
|
||||||
|
```python
|
||||||
|
# Run this in Python shell
|
||||||
|
import src
|
||||||
|
import src.database
|
||||||
|
import src.model
|
||||||
|
import src.gui
|
||||||
|
|
||||||
|
# Check schema file is included
|
||||||
|
from pathlib import Path
|
||||||
|
import src.database
|
||||||
|
db_path = Path(src.database.__file__).parent
|
||||||
|
schema_file = db_path / 'schema.sql'
|
||||||
|
print(f"Schema file exists: {schema_file.exists()}")
|
||||||
|
# Expected: Schema file exists: True
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Issue: ModuleNotFoundError
|
||||||
|
|
||||||
|
**Error:**
|
||||||
|
```
|
||||||
|
ModuleNotFoundError: No module named 'src'
|
||||||
|
```
|
||||||
|
|
||||||
|
**Solution:**
|
||||||
|
```bash
|
||||||
|
# Reinstall with verbose output
|
||||||
|
pip install -e . -v
|
||||||
|
|
||||||
|
# Or try regular install
|
||||||
|
pip install . --force-reinstall
|
||||||
|
```
|
||||||
|
|
||||||
|
### Issue: Entry Points Not Working
|
||||||
|
|
||||||
|
**Error:**
|
||||||
|
```
|
||||||
|
microscopy-detect: command not found
|
||||||
|
```
|
||||||
|
|
||||||
|
**Solution:**
|
||||||
|
```bash
|
||||||
|
# Check if scripts are in PATH
|
||||||
|
which microscopy-detect
|
||||||
|
|
||||||
|
# If not found, check pip install location
|
||||||
|
pip show microscopy-object-detection
|
||||||
|
|
||||||
|
# You might need to add to PATH or use full path
|
||||||
|
~/.local/bin/microscopy-detect # Linux
|
||||||
|
```
|
||||||
|
|
||||||
|
### Issue: Import Errors for PySide6
|
||||||
|
|
||||||
|
**Error:**
|
||||||
|
```
|
||||||
|
ImportError: cannot import name 'QApplication' from 'PySide6.QtWidgets'
|
||||||
|
```
|
||||||
|
|
||||||
|
**Solution:**
|
||||||
|
```bash
|
||||||
|
# Install Qt dependencies (Linux only)
|
||||||
|
sudo apt-get install libxcb-xinerama0
|
||||||
|
|
||||||
|
# Reinstall PySide6
|
||||||
|
pip uninstall PySide6
|
||||||
|
pip install PySide6
|
||||||
|
```
|
||||||
|
|
||||||
|
### Issue: Config Files Not Found
|
||||||
|
|
||||||
|
**Error:**
|
||||||
|
```
|
||||||
|
FileNotFoundError: config/app_config.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
**Solution:**
|
||||||
|
The config file should be created automatically. If not:
|
||||||
|
```bash
|
||||||
|
# Create config directory in your home
|
||||||
|
mkdir -p ~/.microscopy-detect
|
||||||
|
cp config/app_config.yaml ~/.microscopy-detect/
|
||||||
|
|
||||||
|
# Or run from source directory first time
|
||||||
|
cd /home/martin/code/object_detection
|
||||||
|
python main.py
|
||||||
|
```
|
||||||
|
|
||||||
|
## Manual Testing Checklist
|
||||||
|
|
||||||
|
- [ ] Package installs without errors
|
||||||
|
- [ ] Version command works (`microscopy-detect --version`)
|
||||||
|
- [ ] Help command works (`microscopy-detect --help`)
|
||||||
|
- [ ] GUI launches (`microscopy-detect-gui`)
|
||||||
|
- [ ] Can import all modules in Python
|
||||||
|
- [ ] Database schema file is accessible
|
||||||
|
- [ ] Configuration loads correctly
|
||||||
|
|
||||||
|
## Build and Install from Wheel
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build the package
|
||||||
|
python -m build
|
||||||
|
|
||||||
|
# Install from wheel
|
||||||
|
pip install dist/microscopy_object_detection-1.0.0-py3-none-any.whl
|
||||||
|
|
||||||
|
# Test
|
||||||
|
microscopy-detect --version
|
||||||
|
```
|
||||||
|
|
||||||
|
## Uninstall
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip uninstall microscopy-object-detection
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development Workflow
|
||||||
|
|
||||||
|
### After Code Changes
|
||||||
|
|
||||||
|
If installed with `-e` (editable mode):
|
||||||
|
- Python code changes are immediately available
|
||||||
|
- No need to reinstall
|
||||||
|
|
||||||
|
If installed with regular `pip install .`:
|
||||||
|
- Reinstall after changes: `pip install . --force-reinstall`
|
||||||
|
|
||||||
|
### After Adding New Files
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Reinstall to include new files
|
||||||
|
pip install -e . --force-reinstall
|
||||||
|
```
|
||||||
|
|
||||||
|
## Expected Installation Output
|
||||||
|
|
||||||
|
```
|
||||||
|
Processing /home/martin/code/object_detection
|
||||||
|
Installing build dependencies ... done
|
||||||
|
Getting requirements to build wheel ... done
|
||||||
|
Preparing metadata (pyproject.toml) ... done
|
||||||
|
Building wheels for collected packages: microscopy-object-detection
|
||||||
|
Building wheel for microscopy-object-detection (pyproject.toml) ... done
|
||||||
|
Successfully built microscopy-object-detection
|
||||||
|
Installing collected packages: microscopy-object-detection
|
||||||
|
Successfully installed microscopy-object-detection-1.0.0
|
||||||
|
```
|
||||||
|
|
||||||
|
## Success Criteria
|
||||||
|
|
||||||
|
Installation is successful when:
|
||||||
|
1. ✅ No error messages during installation
|
||||||
|
2. ✅ `pip list` shows the package
|
||||||
|
3. ✅ `microscopy-detect --version` returns correct version
|
||||||
|
4. ✅ GUI launches without errors
|
||||||
|
5. ✅ All Python modules can be imported
|
||||||
|
6. ✅ Database operations work
|
||||||
|
7. ✅ Detection functionality works
|
||||||
|
|
||||||
|
## Next Steps After Successful Install
|
||||||
|
|
||||||
|
1. Configure image repository path
|
||||||
|
2. Run first detection
|
||||||
|
3. Train a custom model
|
||||||
|
4. Export results
|
||||||
|
|
||||||
|
For usage instructions, see [QUICKSTART.md](QUICKSTART.md)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[build-system]
|
[build-system]
|
||||||
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"]
|
requires = ["setuptools>=45", "wheel"]
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
@@ -63,10 +63,9 @@ Repository = "https://github.com/yourusername/object_detection"
|
|||||||
microscopy-detect = "src.cli:main"
|
microscopy-detect = "src.cli:main"
|
||||||
|
|
||||||
[project.gui-scripts]
|
[project.gui-scripts]
|
||||||
microscopy-detect-gui = "main:main"
|
microscopy-detect-gui = "src.gui_launcher:main"
|
||||||
|
|
||||||
[tool.setuptools]
|
[tool.setuptools]
|
||||||
package-dir = { "" = "." }
|
|
||||||
packages = [
|
packages = [
|
||||||
"src",
|
"src",
|
||||||
"src.database",
|
"src.database",
|
||||||
@@ -77,10 +76,10 @@ packages = [
|
|||||||
"src.gui.widgets",
|
"src.gui.widgets",
|
||||||
"src.utils",
|
"src.utils",
|
||||||
]
|
]
|
||||||
|
include-package-data = true
|
||||||
|
|
||||||
[tool.setuptools.package-data]
|
[tool.setuptools.package-data]
|
||||||
src = ["database/*.sql"]
|
"src.database" = ["*.sql"]
|
||||||
"" = ["config/*.yaml"]
|
|
||||||
|
|
||||||
[tool.black]
|
[tool.black]
|
||||||
line-length = 88
|
line-length = 88
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -44,7 +44,7 @@ setup(
|
|||||||
"microscopy-detect=src.cli:main",
|
"microscopy-detect=src.cli:main",
|
||||||
],
|
],
|
||||||
"gui_scripts": [
|
"gui_scripts": [
|
||||||
"microscopy-detect-gui=main:main",
|
"microscopy-detect-gui=src.gui_launcher:main",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
keywords="microscopy yolov8 object-detection segmentation computer-vision deep-learning",
|
keywords="microscopy yolov8 object-detection segmentation computer-vision deep-learning",
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ Examples:
|
|||||||
if args.gui:
|
if args.gui:
|
||||||
# Launch GUI
|
# Launch GUI
|
||||||
try:
|
try:
|
||||||
from main import main as gui_main
|
from src.gui_launcher import main as gui_main
|
||||||
|
|
||||||
gui_main()
|
gui_main()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
49
src/gui_launcher.py
Normal file
49
src/gui_launcher.py
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
"""GUI launcher module for microscopy object detection application."""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from PySide6.QtWidgets import QApplication
|
||||||
|
from PySide6.QtCore import Qt
|
||||||
|
|
||||||
|
from src import __version__
|
||||||
|
from src.gui.main_window import MainWindow
|
||||||
|
from src.utils.logger import setup_logging
|
||||||
|
from src.utils.config_manager import ConfigManager
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Launch the GUI application."""
|
||||||
|
# Setup logging
|
||||||
|
config_manager = ConfigManager()
|
||||||
|
log_config = config_manager.get_section("logging")
|
||||||
|
setup_logging(
|
||||||
|
log_file=log_config.get("file", "logs/app.log"),
|
||||||
|
level=log_config.get("level", "INFO"),
|
||||||
|
log_format=log_config.get("format"),
|
||||||
|
)
|
||||||
|
|
||||||
|
# Enable High DPI scaling
|
||||||
|
QApplication.setHighDpiScaleFactorRoundingPolicy(
|
||||||
|
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create Qt application
|
||||||
|
app = QApplication(sys.argv)
|
||||||
|
app.setApplicationName("Microscopy Object Detection")
|
||||||
|
app.setOrganizationName("MicroscopyLab")
|
||||||
|
app.setApplicationVersion(__version__)
|
||||||
|
|
||||||
|
# Set application style
|
||||||
|
app.setStyle("Fusion")
|
||||||
|
|
||||||
|
# Create and show main window
|
||||||
|
window = MainWindow()
|
||||||
|
window.show()
|
||||||
|
|
||||||
|
# Run application
|
||||||
|
sys.exit(app.exec())
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user