$npx -y skills add opengeos/geoai-skills --skill install-geoaiVerify that the geoai Python package is installed and functional. If not, provide installation instructions. Optionally check extra dependencies for deep learning models.
| 1 | Arguments: `$@` |
| 2 | |
| 3 | ## Step 1 -- Check if geoai is importable |
| 4 | |
| 5 | ```bash |
| 6 | python3 -c "import geoai; print(f'geoai v{geoai.__version__}')" |
| 7 | ``` |
| 8 | |
| 9 | - **Success** -> report the version and continue to Step 2 if `--check` or `--extras` was passed, otherwise stop. |
| 10 | - **ImportError** -> go to Step 3. |
| 11 | |
| 12 | ## Step 2 -- Check optional dependencies |
| 13 | |
| 14 | If `--check` is present in `$@`, run a comprehensive dependency check: |
| 15 | |
| 16 | ```bash |
| 17 | python3 -c " |
| 18 | deps = [ |
| 19 | 'geoai', 'geopandas', 'rasterio', 'rioxarray', 'shapely', |
| 20 | 'leafmap', 'numpy', 'pandas', 'matplotlib', |
| 21 | ] |
| 22 | for dep in deps: |
| 23 | try: |
| 24 | mod = __import__(dep) |
| 25 | ver = getattr(mod, '__version__', 'unknown') |
| 26 | print(f'{dep}: {ver}') |
| 27 | except ImportError: |
| 28 | print(f'{dep}: NOT INSTALLED') |
| 29 | " |
| 30 | ``` |
| 31 | |
| 32 | If `--extras` is present in `$@`, also check deep learning dependencies: |
| 33 | |
| 34 | ```bash |
| 35 | python3 -c " |
| 36 | import sys |
| 37 | dl_deps = ['torch', 'torchvision', 'transformers', 'timm', 'segmentation_models_pytorch'] |
| 38 | for dep in dl_deps: |
| 39 | try: |
| 40 | mod = __import__(dep) |
| 41 | ver = getattr(mod, '__version__', 'unknown') |
| 42 | print(f'{dep}: {ver}') |
| 43 | except ImportError: |
| 44 | print(f'{dep}: NOT INSTALLED') |
| 45 | |
| 46 | try: |
| 47 | import torch |
| 48 | if torch.cuda.is_available(): |
| 49 | print(f'CUDA: {torch.version.cuda} (device: {torch.cuda.get_device_name(0)})') |
| 50 | else: |
| 51 | print('CUDA: not available (CPU only)') |
| 52 | except ImportError: |
| 53 | print('CUDA: torch not installed') |
| 54 | " |
| 55 | ``` |
| 56 | |
| 57 | Report the results and note any missing packages. |
| 58 | |
| 59 | ## Step 3 -- Installation instructions |
| 60 | |
| 61 | If geoai is not installed, tell the user: |
| 62 | |
| 63 | > **geoai is not installed.** Install it with: |
| 64 | > |
| 65 | > ``` |
| 66 | > pip install geoai-py |
| 67 | > ``` |
| 68 | > |
| 69 | > For GPU-accelerated AI models (object detection, segmentation), also install PyTorch: |
| 70 | > |
| 71 | > ``` |
| 72 | > pip install torch torchvision |
| 73 | > ``` |
| 74 | > |
| 75 | > For the full set of optional dependencies: |
| 76 | > |
| 77 | > ``` |
| 78 | > pip install "geoai-py[extra]" |
| 79 | > ``` |
| 80 | |
| 81 | Stop after showing the instructions. Do not attempt to install automatically unless the user explicitly asks. |