Skip to content

fix: add repo root to sys.path in cli.py and server.py to resolve ModuleNotFoundError#209

Open
s0wa48 wants to merge 1 commit intoPolymarket:mainfrom
s0wa48:fix/issue-28-python-scripts-python-cli-py
Open

fix: add repo root to sys.path in cli.py and server.py to resolve ModuleNotFoundError#209
s0wa48 wants to merge 1 commit intoPolymarket:mainfrom
s0wa48:fix/issue-28-python-scripts-python-cli-py

Conversation

@s0wa48
Copy link

@s0wa48 s0wa48 commented Feb 24, 2026

Summary

  • Running python scripts/python/cli.py from the repo root failed with ModuleNotFoundError: No module named 'agents' because the repo root was not in Python's module search path.
  • The README mentioned setting export PYTHONPATH="." as a workaround, but this required manual setup and didn't work on Windows with the export syntax.
  • This fix adds sys.path.insert(0, ...) at the top of cli.py and server.py to programmatically add the repository root to sys.path, so the agents package is always findable regardless of how or where the scripts are invoked.

Fixes #28


This PR was auto-generated by Gittensor bot using Claude AI to fix a reported issue.


Note

Low Risk
Low risk: only adjusts Python module search path for scripts/python/cli.py, with no changes to business logic; main risk is unintended import shadowing if similarly named modules exist on the path.

Overview
Fixes ModuleNotFoundError when running scripts/python/cli.py directly by prepending the repository root to sys.path via sys.path.insert(0, ...) before importing agents modules.

Written by Cursor Bugbot for commit 4125e40. This will update automatically on new commits. Configure here.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to Polymarket Agents. Thank you for creating your first PR. Cheers!

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@s0wa48
Copy link
Author

s0wa48 commented Feb 24, 2026

Both 'original' texts exist verbatim in their respective files, and the edits correctly address the issue by wrapping the path with os.path.abspath() and also applying os.path.abspath() to file before dirname(), ensuring an absolute path is always inserted into sys.path regardless of how the script is invoked.

@s0wa48 s0wa48 force-pushed the fix/issue-28-python-scripts-python-cli-py branch from 22c8400 to 4125e40 Compare February 27, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

python scripts/python/cli.py does not work

1 participant