Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name '_thread' from 'moves' (unknown location) #369

Closed
kgilpin opened this issue Aug 12, 2024 · 2 comments
Closed
Assignees
Labels
navie-plan Plan the issue with Navie

Comments

@kgilpin
Copy link
Contributor

kgilpin commented Aug 12, 2024

https://github.com/getappmap/SWE-bench/actions/runs/10354682656/job/28660536027#step:7:4432

Traceback (most recent call last):
  File "/home/runner/work/SWE-bench/SWE-bench/solver/solve/solver.py", line 20, in <module>
    from solve.steps.build_task_manager import build_task_manager
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "/home/runner/work/SWE-bench/SWE-bench/solver/solve/../solve/steps/build_task_manager.py", line 3, in <module>
    from swebench.harness.context_manager import TaskEnvContextManager
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "/home/runner/work/SWE-bench/SWE-bench/swebench/__init__.py", line 15, in <module>
    from swebench.harness.run_evaluation import (
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "/home/runner/work/SWE-bench/SWE-bench/swebench/harness/run_evaluation.py", line 5, in <module>
    import datasets
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/datasets/__init__.py", line 17, in <module>
    from .arrow_dataset import Dataset
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/datasets/arrow_dataset.py", line 59, in <module>
    import pandas as pd
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/pandas/__init__.py", line 49, in <module>
    from pandas.core.api import (
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/pandas/core/api.py", line 1, in <module>
    from pandas._libs import (
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/pandas/_libs/__init__.py", line 18, in <module>
    from pandas._libs.interval import Interval
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "interval.pyx", line 1, in init pandas._libs.interval
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "hashtable.pyx", line 1, in init pandas._libs.hashtable
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "missing.pyx", line 1, in init pandas._libs.missing
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/pandas/_libs/tslibs/__init__.py", line 40, in <module>
    from pandas._libs.tslibs.conversion import localize_pydatetime
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "conversion.pyx", line 1, in init pandas._libs.tslibs.conversion
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "offsets.pyx", line 1, in init pandas._libs.tslibs.offsets
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "timestamps.pyx", line 1, in init pandas._libs.tslibs.timestamps
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "timedeltas.pyx", line 1, in init pandas._libs.tslibs.timedeltas
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "timezones.pyx", line 24, in init pandas._libs.tslibs.timezones
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/dateutil/tz/__init__.py", line 2, in <module>
    from .tz import *
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/wrapt/wrappers.py", line 620, in __call__
    return self._self_wrapper(self.__wrapped__, instance,
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/_appmap/importer.py", line 279, in wrapped_exec_module
    exec_module(*args, **kwargs)
  File "/usr/share/miniconda/envs/swe-bench/lib/python3.9/site-packages/dateutil/tz/tz.py", line 21, in <module>
    from six.moves import _thread
ImportError: cannot import name '_thread' from 'moves' (unknown location)

@kgilpin kgilpin added the navie-plan Plan the issue with Navie label Aug 12, 2024
Copy link

Title

Resolve ImportError: cannot import name '_thread' from 'moves'

Problem

The application is encountering an ImportError, specifically indicating that it cannot import the name '_thread' from the 'moves' module. This error occurs when attempting to import the TaskEnvContextManager in the build_task_manager module, originating from various other downstream imports.

Analysis

The root cause of the problem appears to be an incompatibility or misconfiguration involving the six module, specifically the six.moves abstraction. The _thread module is a standard library in Python 3, but it appears this import might be referencing Python 2 naming conventions or incorrect module paths.

The import error primarily arises from the dateutil package, which is likely using six.moves for Python 2/3 compatibility layers. Given the heavy usage of threading and importing across multiple files, ensuring six is correctly installed and configured, and reviewing how threading modules are managed in six may resolve the issue.

Proposed Changes

To solve the problem, follow these steps:

  1. Verify six module installation:
    Ensure that the six module is properly installed in your environment. You can do this by running:

    pip install six
  2. Update six version:
    Ensure that you're using the latest version of the six module, as older versions might have compatibility issues. Update six using:

    pip install --upgrade six
  3. Review and update six.moves references:
    Review the files related to threading and importing, particularly those that could be using six for compatibility. Update them to correctly import the _thread module using six.moves.

  4. Modify import statement:
    Locate the incorrect import statement in dateutil/tz/tz.py and correct it to properly reference the _thread module:

    from six.moves import _thread

Steps to apply these changes:

  1. Verify six module installation and update:
    Ensure the six module is present and updated in the environment running the code.

  2. Update import statements in the following files:

    • swebench/harness/context_manager.py: Ensure correct usage of _thread.

      from six.moves import _thread
    • Check other places where six.moves might be referenced and update accordingly.

  3. Inspect the dateutil package:

    • Ensure that the dateutil package's usage of six.moves is correct and doesn't lead to the ImportError.
  4. Configuration and import management:

    • Ensure no conflicting versions of modules and packages are installed which might cause differing import paths.

By following these steps, the ImportError related to _thread from six.moves should be resolved, allowing for smooth execution of your application.

@apotterri
Copy link
Contributor

This error also occurs when run without the agent. Closing this in favor of getappmap/SWE-bench#98 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
navie-plan Plan the issue with Navie
Projects
None yet
Development

No branches or pull requests

2 participants