Skip to content

Empty __init__.py: Need from ccx2paraview import ccx2paraview instead of import ccx2paraview #31

@pstelzig

Description

@pstelzig

Problem description

When installing ccx2paraview under Ubuntu 22.04 using pip like

pip3 install --user ccx2paraview

pip will create a file ~/.local/lib/python3.10/site-packages/ccx2paraview/__init__.py that turns ccx2paraview into a Python module.

The __init__.py is empty, and therefore the module ccx2paraview -- when importing in a Python file -- has no members except again the submodule ccx2paraview (because the folder ~/.local/lib/python3.10/site-packages/ccx2paraview contains the file ccx2paraview.py).

Hence, in order to access the module elements from ccx2paraview one has to state from ccx2paraview import ccx2paraview and then all elements are again available like e.g. ccx2paraview.Converter

Desired behavior

After import ccx2paraview in a Python file have the relevant members of ccx2paraview available like ccx2paraview.Converter etc.

Potential fix

Include a file __init__.py into the ccx2paraview repository with content like

from .ccx2paraview import *

to import everything from the ccx2paraview.py or

from .ccx2paraview import Converter
from .ccx2paraview import <whatever a user needs>

I modified the empty __init__.py like this and it worked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions