Skip to content

Issue when importing EIAClient: "ModuleNotFoundError: No module named 'eia.data'" #2

@dajsfiles

Description

@dajsfiles

When I download the notebook in the description and try to install it after installing python-eia, I run into the following issue when running:

from eia import EIAClient

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[9], [line 1](vscode-notebook-cell:?execution_count=9&line=1)
----> [1](vscode-notebook-cell:?execution_count=9&line=1) from eia import EIAClient

File ~/.local/lib/python3.10/site-packages/eia/__init__.py:9
      7 from .client import EIAClient, EIAError
      8 from .cache import CacheConfig
----> [9](https://vscode-remote+codespaces-002bcuddly-002ddoodle-002d54x76p5w6qrfv44j.vscode-resource.vscode-cdn.net/workspaces/python-for-time-series-forecasting-5246009/data/EIA/Scripts/~/.local/lib/python3.10/site-packages/eia/__init__.py:9) from . import catalog
     11 __version__ = "0.1.0"
     12 __all__ = ["EIAClient", "EIAError", "CacheConfig", "catalog"]

File ~/.local/lib/python3.10/site-packages/eia/catalog.py:85
     81 from eia.catalog_manager import EIACatalogManager as _EIACatalogManager
     83 _mgr = _EIACatalogManager()
---> [85](https://vscode-remote+codespaces-002bcuddly-002ddoodle-002d54x76p5w6qrfv44j.vscode-resource.vscode-cdn.net/workspaces/python-for-time-series-forecasting-5246009/data/EIA/Scripts/~/.local/lib/python3.10/site-packages/eia/catalog.py:85) ROUTES: dict[str, RouteInfo] = {r.route: r for r in _mgr._load_routes()}
     86 RECIPES: dict[str, Recipe] = {r.id: r for r in _mgr._load_recipes()}
     89 # ── Convenience functions ──────────────────────────────────────────────

File ~/.local/lib/python3.10/site-packages/eia/catalog_manager.py:69, in EIACatalogManager._load_routes(self)
     66 if self._routes is not None:
     67     return self._routes
---> [69](https://vscode-remote+codespaces-002bcuddly-002ddoodle-002d54x76p5w6qrfv44j.vscode-resource.vscode-cdn.net/workspaces/python-for-time-series-forecasting-5246009/data/EIA/Scripts/~/.local/lib/python3.10/site-packages/eia/catalog_manager.py:69) data = self._read_yaml("routes.yaml")
     70 routes: list[RouteInfo] = []
     71 for entry in data.get("routes", []):

File ~/.local/lib/python3.10/site-packages/eia/catalog_manager.py:60, in EIACatalogManager._read_yaml(filename)
     57 @staticmethod
     58 def _read_yaml(filename: str) -> dict:
     59     """Read a YAML file from the ``eia.data`` package."""
---> [60](https://vscode-remote+codespaces-002bcuddly-002ddoodle-002d54x76p5w6qrfv44j.vscode-resource.vscode-cdn.net/workspaces/python-for-time-series-forecasting-5246009/data/EIA/Scripts/~/.local/lib/python3.10/site-packages/eia/catalog_manager.py:60)     ref = importlib.resources.files("eia.data").joinpath(filename)
     61     with importlib.resources.as_file(ref) as path:
     62         return yaml.safe_load(path.read_text(encoding="utf-8"))

File /usr/local/lib/python3.10/importlib/_common.py:22, in files(package)
     17 def files(package):
     18     # type: (Package) -> Traversable
     19     """
     20     Get a Traversable resource from a package
     21     """
---> [22](https://vscode-remote+codespaces-002bcuddly-002ddoodle-002d54x76p5w6qrfv44j.vscode-resource.vscode-cdn.net/usr/local/lib/python3.10/importlib/_common.py:22)     return from_package(get_package(package))

File /usr/local/lib/python3.10/importlib/_common.py:66, in get_package(package)
     60 def get_package(package):
     61     # type: (Package) -> types.ModuleType
     62     """Take a package name or module object and return the module.
     63 
     64     Raise an exception if the resolved module is not a package.
     65     """
---> [66](https://vscode-remote+codespaces-002bcuddly-002ddoodle-002d54x76p5w6qrfv44j.vscode-resource.vscode-cdn.net/usr/local/lib/python3.10/importlib/_common.py:66)     resolved = resolve(package)
     67     if wrap_spec(resolved).submodule_search_locations is None:
     68         raise TypeError(f'{package!r} is not a package')

File /usr/local/lib/python3.10/importlib/_common.py:57, in resolve(cand)
     55 def resolve(cand):
     56     # type: (Package) -> types.ModuleType
---> [57](https://vscode-remote+codespaces-002bcuddly-002ddoodle-002d54x76p5w6qrfv44j.vscode-resource.vscode-cdn.net/usr/local/lib/python3.10/importlib/_common.py:57)     return cand if isinstance(cand, types.ModuleType) else importlib.import_module(cand)

File /usr/local/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
    124             break
    125         level += 1
--> [126](https://vscode-remote+codespaces-002bcuddly-002ddoodle-002d54x76p5w6qrfv44j.vscode-resource.vscode-cdn.net/usr/local/lib/python3.10/importlib/__init__.py:126) return _bootstrap._gcd_import(name[level:], package, level)

ModuleNotFoundError: No module named 'eia.data'

I can't find anyone else having this issue. Do I need to install an older version for this to work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions