Repository: explodinggradients/ragas
Issue: ModuleNotFoundError: No module named 'ragas.testset'; 'ragas' is not a package
Root cause: Environment Incompatibility

[ ] I have checked the [documentation](https://docs.ragas.io/) and related resources and couldn't resolve my bug.

Describe the bug
Just trying to import the package while pip show ragas correctly shows the package

Ragas version: 0.1.10
Python version: 3.10.12

Code to Reproduce
from ragas.testset.generator import TestsetGenerator
from ragas.testset.evolutions import simple, reasoning, multi_context

Error trace
Traceback (most recent call last):
  File "/home/ubuntu/scp-analyzer/rag-old/ragas.py", line 2, in <module>
    from ragas.testset.generator import TestsetGenerator
  File "/home/ubuntu/scp-analyzer/rag-old/ragas.py", line 2, in <module>
    from ragas.testset.generator import TestsetGenerator
ModuleNotFoundError: No module named 'ragas.testset'; 'ragas' is not a package

Additional context
I just installed the package (working in VSCode)

<!-- Greeting -->
Hello @Rugved2204! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this issue together!

<!-- Answer -->
To resolve the `ModuleNotFoundError: No module named 'ragas.testset'; 'ragas' is not a package` error, follow these steps:

1. **Check Installation**: Ensure that the `ragas` package is installed correctly. You can reinstall it using pip:
    ```sh
    pip install --upgrade ragas
    ```

2. **Directory Structure**: Ensure that your project directory structure is correct. It should look something like this:
    ```
    your_project/
    ├── src/
    │   └── ragas/
    │       ├── __init__.py
    │       └── testset/
    │           ├── __init__.py
    │           └── generator.py
    └── your_script.py
    ```

3. **PYTHONPATH**: Make sure that the `src` directory is included in your `PYTHONPATH`. You can set it in your environment or within your script:
    ```sh
    export PYTHONPATH=$PYTHONPATH:/path/to/your_project/src
    ```

4. **Import Statement**: Ensure that your import statement in your script is correct. For example:
    ```py
    from ragas.testset.generator import TestsetGenerator
    ```

5. **Testing Imports**: Create a test script to verify that the modules are being imported correctly. For example:
    ```py
    def test_import():
        import ragas
        from ragas.testset.generator import TestsetGenerator

        assert TestsetGenerator is not None
        assert ragas is not None

    def test_import_metrics():
        from ragas.metrics.critique import harmfulness

        assert harmfulness is not None
    ```

By following these steps, you should be able to resolve the `ModuleNotFoundError` and successfully import modules from the `ragas` package <sup>[[1]](https://github.com/explodinggradients/ragas/blob/main/src/ragas/testset/__init__.py)</sup><sup>[[2]](https://github.com/explodinggradients/ragas/blob/main/tests/unit/test_import.py)</sup><sup>[[3]](https://github.com/explodinggradients/ragas/blob/main/tests/unit/test_simple.py)</sup>.


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*


Hello @dosu. I tried all the things mentioned by you. The issue still persists.

<!-- Answer -->
If the issue still persists after following the previous steps, here are a few additional things to check:

1. **Script Name**: Ensure that your script is not named `ragas.py` or any other name that conflicts with the package name. Rename your script to something else, like `my_script.py`.

2. **Virtual Environment**: Make sure you are using a virtual environment and that it is activated. Sometimes, the global Python environment might have conflicting packages. You can create and activate a virtual environment using:
    ```sh
    python -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
    pip install ragas
    ```

3. **Check for Conflicting Files**: Ensure there are no files or directories named `ragas` in your project directory that might be shadowing the installed package.

4. **Reinstall the Package**: Sometimes, a fresh installation can resolve issues. Uninstall and then reinstall the `ragas` package:
    ```sh
    pip uninstall ragas
    pip install ragas
    ```

5. **Verify Installation Path**: Check where the `ragas` package is installed and ensure it is in the correct location. You can do this by running:
    ```sh
    python -c "import ragas; print(ragas.__file__)"
    ```

6. **Check for Updates**: Ensure that you have the latest version of the `ragas` package. Sometimes, bugs are fixed in newer releases:
    ```sh
    pip install --upgrade ragas
    ```

7. **Debugging Imports**: Add some debug prints to check the import paths:
    ```py
    import sys
    print(sys.path)
    from ragas.testset.generator import TestsetGenerator
    ```

By following these additional steps, you should be able to resolve the `ModuleNotFoundError` and successfully import modules from the `ragas` package.


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*


@dosu Yes my script was named as ragas.py, The issue is now solved as I changed the name of the script. Thank you.

<!-- Answer -->
Great to hear that the issue is resolved! If you have any more questions or run into any other issues, feel free to ask. Happy coding!


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*