コンテンツにスキップ

EvoSpikeNet SDK インストールガイド

Author: Masahiro Aoki

最終更新日: 2026年1月15日

概要

このガイドでは、EvoSpikeNet Python SDKのインストールとセットアップ方法について説明します。SDKはPythonパッケージとして提供されており、pipを使用して簡単にインストールできます。

前提条件

システム要件

  • Python: 3.8 以上
  • OS: Linux, macOS, Windows
  • メモリ: 最低 4GB RAM(推奨 8GB以上)
  • ストレージ: 最低 2GB の空き容量

依存関係

SDKは以下の主要な依存関係があります:

  • requests>=2.25.0: HTTPクライアント
  • typing-extensions>=4.0.0: 型ヒント拡張
  • dataclasses>=0.6: データクラス(Python 3.6以下の場合)
  • websockets>=10.0: WebSocket通信(オプション)
  • aiohttp>=3.8.0: 非同期HTTP(オプション)

インストール方法

方法1: pipを使用したインストール(推奨)

プロジェクトのルートディレクトリで以下のコマンドを実行してください:

# 開発モードでのインストール(推奨)
pip install -e .

# または、PyPIからインストール(利用可能な場合)
pip install evospikenet-sdk

方法2: 手動インストール

依存関係を手動でインストールする場合:

# 必須依存関係
pip install requests typing-extensions

# オプション依存関係(Jupyter統合用)
pip install ipython jupyter

# オプション依存関係(WebSocket用)
pip install websockets

# オプション依存関係(非同期処理用)
pip install aiohttp

方法3: Dockerを使用したインストール

Docker環境を使用する場合:

# Dockerイメージのビルド
docker build -t evospikenet-sdk .

# コンテナ実行
docker run -it evospikenet-sdk

環境設定

Python仮想環境の作成(推奨)

# venvを使用する場合
python -m venv evospikenet_env
source evospikenet_env/bin/activate  # Linux/macOS
# evospikenet_env\Scripts\activate     # Windows

# インストール
pip install -e .

# condaを使用する場合
conda create -n evospikenet python=3.9
conda activate evospikenet
pip install -e .

APIサーバーの起動

SDKを使用する前に、EvoSpikeNet APIサーバーが起動している必要があります:

# Docker Composeを使用する場合(推奨)
sudo ./scripts/run_api_server.sh

# または、全サービスを起動
sudo ./scripts/run_frontend_cpu.sh

# 特定のコンポーネントのみ起動
docker-compose -f docker-compose.yml up api

環境変数の設定

API認証を設定する場合:

# Linux/macOS
export EVOSPIKENET_API_KEY=your_api_key_here
export EVOSPIKENET_API_URL=http://localhost:8000

# Windows
set EVOSPIKENET_API_KEY=your_api_key_here
set EVOSPIKENET_API_URL=http://localhost:8000

インストールの検証

基本的な動作確認

# Pythonインタプリタで確認
python -c "

<!-- from evospikenet.sdk import EvoSpikeNetAPIClient -->
print('SDK imported successfully')

client = EvoSpikeNetAPIClient()
print('Client initialized successfully')

# ヘルスチェック
try:
    health = client.health_check()
    print(f'Health check: {health}')
except Exception as e:
    print(f'Health check failed: {e}')
"

Jupyter Notebookでの確認

# Jupyter Notebookでの確認
<!-- TODO: update or remove - import fail JupyterAPIClient -->
print("Jupyter integration available")

client = JupyterAPIClient()
client.show_server_info()

高度な設定

プロキシ設定

プロキシ環境で使用する場合:

import os
<!-- モジュール 'evospikenet' が見つかりませんパッケージ内の移動/名前変更を確認してください -->
<!-on['HTTP_PROXY'] = 'http://proxy.example.com:8080'
os.environ['HTTPS_PROXY'] = 'http://proxy.example.com:8080'

# または、セッションで直接設定
import requests
session = requests.Session()
session.proxies = {
    'http': 'http://proxy.example.com:8080',
    'https': 'http://proxy.example.com:8080',
}

client = EvoSpikeNetAPIClient(session=session)

SSL証明書の設定

カスタムSSL証明書を使用する場合:

<!-- TODO: update<!-- モジュール 'evospikenet' が見つかりませんパッケージ内の移動/名前変更を確認してください -->kenet.sdk import EvoSpikeNetent.session.verify = '/path/to/ca-cert.pem'

# SSL検証を無効化(開発環境のみ)
# 注意: 本番環境では使用しないでください
client.session.verify = False

タイムアウトとリトライの設定

ネットワーク条件に応じた設定:

<!-- TODO: update or remove - impo<!-- モジュール 'evospikenet' が見つかりませんパッケージ内の移動/名前変更を確認してください -->EvoSpikeNetAPIClient -->

# 遅いネットワーク向けの設定
client = E最大5回リトライ
)

プラットフォーム別のインストール

Linux

# Ubuntu/Debian
sudo apt-get update
sudo apt-get install python3 python3-pip python3-venv

# CentOS/RHEL
sudo yum install python3 python3-pip
# または
sudo dnf install python3 python3-pip

# SDKインストール
pip3 install -e .

macOS

# Homebrewを使用する場合
brew install python3

# SDKインストール
pip3 install -e .

# または、システムPythonを使用
pip install -e .

Windows

# Pythonをインストール後
python -m pip install --upgrade pip
pip install -e .

# PowerShellの場合
python -m venv evospikenet_env
.\evospikenet_env\Scripts\Activate.ps1
pip install -e .

Google Colab

# Colab環境でのインストール
!git clone https://github.com/your-repo/EvoSpikeNet.git
%cd EvoSpikeNet
!pip install -e .

# 使用例
```python
from evospikenet.sdk import EvoSpikeNetAPIClient

# Simple guarded initialization example for Colab / notebook
try:
    client = EvoSpikeNetAPIClient(base_url="https://your-api-server.com")
    print("EvoSpikeNet API client initialized")
except Exception:
    print("EvoSpikeNet API client unavailable in this environment; ensure package is installed and PYTHONPATH is set.")
  1. ImportError: No module named 'typing_extensions'

    pip install typing-extensions
    

  2. Jupyter Notebookでのエラー

    pip install ipython jupyter
    # または
    conda install ipython jupyter
    

  3. WebSocket機能が利用できない

    pip install websockets
    

  4. 非同期機能が利用できない

    pip install aiohttp
    

バージョン競合の解決

requirements.txtでバージョン固定する場合:

pip install -r requirements.txt

requirements.txtの内容例:

requests>=2.25.0,<3.0.0
typing-extensions>=4.0.0,<5.0.0
websockets>=10.0,<11.0.0
aiohttp>=3.8.0,<4.0.0

APIサーバーの接続確認

基本的な接続テスト

from evospikenet.sdk import EvoSpikeNetAPIClient

def test_connection():
    try:
        client = EvoSpikeNetAPIClient()
    except Exception as e:
        print(f"✗ Client initialization failed: {e}")
        return False

    # Health check (guarded)
    if hasattr(client, "health_check"):
        try:
            health = client.health_check()
            print(f"✓ Health: {health}")
        except Exception as e:
            print(f"✗ Health check failed: {e}")
            return False
    else:
        print("Health check API not available; skipping.")

    return True

def test_basic_functionality():
    try:
        client = EvoSpikeNetAPIClient()
    except Exception as e:
        print(f"✗ Client init failed: {e}")
        return False

    if hasattr(client, "get_server_info"):
        try:
            info = client.get_server_info()
            print(f"✓ Server info: {info}")
            return True
        except Exception as e:
            print(f"✗ Server info failed: {e}")
            return False
    else:
        print("get_server_info API not available; skipping.")
        return False

if __name__ == "__main__":
    print("Testing EvoSpikeNet SDK connection...")
    if test_connection():
        test_basic_functionality()

詳細な診断

from evospikenet.sdk import EvoSpikeNetAPIClient
import socket

def diagnose_connection():
    try:
        client = EvoSpikeNetAPIClient(timeout=10)
    except Exception as e:
        print(f"✗ Client init failed: {e}")
        return

    print("=== Connection Diagnostics ===")

    # 1. DNS resolution (simple check)
    try:
        ip = socket.gethostbyname('localhost')
        print(f"✓ DNS resolution: localhost -> {ip}")
    except Exception as e:
        print(f"✗ DNS resolution failed: {e}")
        return

    # 2. Port connectivity
    try:
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.settimeout(5)
        result = sock.connect_ex(("localhost", 8000))
        sock.close()
        if result == 0:
            print("✓ Port 8000 accessible")
        else:
            print("✗ Port 8000 not accessible")
            return
    except Exception as e:
        print(f"✗ Port test failed: {e}")
        return

    # 3. HTTP health check (guarded)
    if hasattr(client, "health_check"):
        try:
            health = client.health_check()
            print(f"✓ HTTP connection: {health}")
        except Exception as e:
            print(f"✗ HTTP connection failed: {e}")
    else:
        print("Health check API not available; skip HTTP test.")

    # 4. Stats (guarded)
    if hasattr(client, "get_stats"):
        try:
            stats = client.get_stats()
            print(f"✓ Client stats: {stats}")
        except Exception as e:
            print(f"✗ Stats retrieval failed: {e}")
    else:
        print("Stats API not available; skipping.")

if __name__ == "__main__":
    diagnose_connection()

アップグレード

SDKのアップグレード

# 最新バージョンにアップグレード
git pull origin main
pip install -e . --upgrade

# または、特定のバージョン
git checkout v1.2.3
pip install -e .

依存関係の更新

# 全ての依存関係を更新
pip install -e . --upgrade

# 特定の依存関係のみ更新
pip install --upgrade requests
pip install --upgrade typing-extensions

アンインストール

SDKをアンインストールする場合:

# 開発モードインストールの場合
pip uninstall evospikenet

# 仮想環境を削除する場合
rm -rf evospikenet_env  # Linux/macOS
# rmdir /s evospikenet_env  # Windows

サポート

ヘルプの取得

一般的な問題

  1. "ModuleNotFoundError": Pythonパスが正しく設定されているか確認してください。
  2. "Connection refused": APIサーバーが起動しているか確認してください。
  3. "SSL errors": SSL証明書の設定を確認してください。
  4. "Timeout errors": ネットワーク接続とタイムアウト設定を確認してください。

ログの確認

詳細なデバッグ情報が必要な場合:

import logging

# デバッグログの有効化
logging.basicConfig(level=logging.DEBUG)

```python
import logging
from evospikenet.sdk import EvoSpikeNetAPIClient

# Enable debug logging
logging.basicConfig(level=logging.DEBUG)

try:
    client = EvoSpikeNetAPIClient()
    if hasattr(client, "generate"):
        result = client.generate("Test prompt")
        print("Generate result:", result)
    else:
        print("Generate API not available on this client implementation.")
except Exception as e:
    print("EvoSpikeNet SDK client not available or generate() failed:", e)
```

次のステップ

インストールが完了したら、以下のドキュメントを参照してください:

  1. SDKクイックスタート: 基本的な使用方法
  2. **[SD
  3. SDK設定: 高度な設定オプション

SDKの使用を開始する準備が整いました! /Users/maoki/Documents/GitHub/EvoSpikeNet/docs/SDK_INSTALLATION_GUIDE.md