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

Import weirdness #34

Open
ryanmrichard opened this issue Aug 18, 2022 · 2 comments
Open

Import weirdness #34

ryanmrichard opened this issue Aug 18, 2022 · 2 comments

Comments

@ryanmrichard
Copy link
Member

ryanmrichard commented Aug 18, 2022

Admittedly I'm pretty weak when it comes to the mechanics of Python's import mechanism, so this might be a Python error on my side.

Anyways, since this works:

import simde

mol = simde.chemist.Molecule()

I would have expected:

import simde.chemist as chemist

mol = chemist.Molecule()

to work. Instead I get ModuleNotFoundError: No module named 'simde.chemist'. Assuming this isn't a problem with my Python, I think what's happening is that the Chemist found by SimDE isn't actually a Python module (i.e., it doesn't have an __init__.py file). Interestingly:

import simde
import chemist

mol = simde.chemist.Molecule()
mol = chemist.chemist.Molecule()

works which suggests to me that we might have a Python stack where each module x includes copies of the repos below it, instead of simply than importing them as submodules.

I'm going to throw this issue in the .github repo, but it should be moved to the appropriate repo if .github isn't it.

@wadejong
Copy link

wadejong commented Sep 14, 2022

This is a standard Python feature. The solution that we need to use is "from x import y". Hence:

from simde import chemist 

mol = chemist.Molecule() 

Others that work:

from chemist import chemist

from nwchemex import chemist

@ryanmrichard
Copy link
Member Author

I don't think this is the same as #31. I think this is a problem with us actually copying the subpackages instead of importing them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants