iflytek/astron-agent · error · FileNotFoundError
can not find
Error message
can not find {relative_path} What it means
start_service() computes a relative path from the current working directory to app/start_server.py and raises FileNotFoundError when that path does not exist. The launcher must be run from the aitools plugin root directory because the path is cwd-relative.
Solutions
- cd into core/plugin/aitools before launching the service.
- Fix the IDE/docker working directory to core/plugin/aitools.
- Check the printed path in the error to see which directory was expected.
- Refactor start_service to use an absolute path derived from __file__ instead of cwd-relative resolution.
Example fix
// before subprocess.run([sys.executable, relative_path], check=True) // after abs_path = Path(__file__).resolve().parent / "app/start_server.py" subprocess.run([sys.executable, abs_path], check=True)
Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
start_dir = Path('core/plugin/aitools')
assert (start_dir / 'app/start_server.py').exists(), 'run from repo root or fix cwd' Type guard
def launcher_ready() -> bool:
return (Path(__file__).resolve().parent / 'app/start_server.py').exists() Try / catch
try:
start_service()
except FileNotFoundError as e:
print(f'Launcher must run from the aitools plugin directory: {e}')
sys.exit(2) Prevention
- Always launch from core/plugin/aitools
- Set the working directory explicitly in IDE run configs and Dockerfile WORKDIR
- Prefer absolute paths built from __file__
- Check the path in the error message against your cwd
When it happens
Trigger: Running `python -m ...main` or main() from any directory other than core/plugin/aitools, so (Path(__file__).parent).relative_to(Path.cwd()) resolves to a path where app/start_server.py is absent.
Common situations: Starting the service from the repo root instead of the plugin directory, IDE run configurations with the wrong working directory, container WORKDIR pointing elsewhere, symlinked installs.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- can not find
- alembic.ini not found
- Config file not found
- credential file is unavailable
- database config is nil or dbType is empty
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/d5ef084729a85afa.
Report an issue: GitHub.
Appendix: source
Thrown at core/plugin/aitools/main.py:52
new_paths_str = os.pathsep.join(new_paths)
if python_path:
os.environ["PYTHONPATH"] = f"{new_paths_str}{os.pathsep}{python_path}"
else:
os.environ["PYTHONPATH"] = new_paths_str
print(f"🔧 PYTHONPATH: {os.environ['PYTHONPATH']}")
def start_service() -> None:
"""Start FastAPI service"""
print("\n🚀 Starting AITools service...")
try:
# Start FastAPI application
relative_path = (Path(__file__).resolve().parent).relative_to(
Path.cwd()
) / "app/start_server.py"
if not relative_path.exists():
raise FileNotFoundError(f"can not find {relative_path}")
subprocess.run([sys.executable, relative_path], check=True)
except subprocess.CalledProcessError as e:
print(f"❌ Service startup failed: {e}")
sys.exit(1)
except KeyboardInterrupt:
print("\n🛑 Service stopped")
sys.exit(0)
def main() -> None:
"""Main function"""
print("🌟 AITools Development Environment Launcher")
print("=" * 50)
# Set up Python path
setup_python_path()
# Load environment configurationView on GitHub (pinned to 5e758547a8)