Skip to content

Cannot import module from .pyc file #42

@markfickett

Description

@markfickett

When I try to import a module that is defined (only) in a .pyc file, I get an import error. For example, when my directory contains:

__init__.py
mark.pyc  # but not mark.py

and init contains

import mark

I get an error saying

ImportError: No module named mark

The use case is that I'm writing competing AIs with some friends, and so we want to let our AIs interact (thus checking them into a shared git repo), but we don't want to be able to see each other's implementations (thus checking in *.pyc not *.py).

The repo in question is https://github.com/markfickett/modernart/tree/include-deps . Note that as checked in it uses importlib to find and import the player (*.pyc) modules in players/init.py, but I edited it to be a direct import for debugging purposes in QPython.

Thanks for making and releasing QPython! It's great to be able to do some Python coding on my phone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions