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 2 commits 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 2 commits 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
Small, localized change to Python startup path for two scripts; low likelihood of side effects beyond import resolution.

Overview
Fixes import failures when running scripts/python/cli.py or scripts/python/server.py directly by programmatically prepending the repo root to sys.path.

This removes reliance on manually setting PYTHONPATH and ensures the agents package can be imported regardless of the current working directory/platform.

Written by Cursor Bugbot for commit 22c8400. 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.

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