-
Notifications
You must be signed in to change notification settings - Fork 11
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
module errors: ModuleNotFoundError: No module named 'lantz.errors' #1
Comments
This is an (unintended) consequence of the namespace packages reorganization.
(we should do it for all the lantz codebase) |
I wonder if there is any way to expose it while keeping namespace packages. |
maybe you can tweak the |
Namespace packages are different beast, I think it will not work. But I will try. |
Ok. I am not very experienced with them. |
Fixed! |
And thanks for the feedback. Changing the structure of a project often break some internal imports specially in decoupled projects. |
Would be interesting to know if there is a better solution compared to this workaround of changing all the imports, which kinda makes the code clunkier. |
I think a good way would be to promote InstrumentError to the root of lantz. In that way, you would just do:
|
Hm, could it be that you are not allowed to have an
which could be what is observed here. It also says
which is not present in the lantz setup.py (only lantz itself is mentioned)- maybe adding all the subpackages would also fix this issue. |
I do not think this is the problem. The lantz root package is properly integrated into the namespace thanks to: __path__ = __import__('pkgutil').extend_path(__path__, __name__) The problem is that errors is not re-exported. You se, errors is acutally a subpackage of lantz core and even though I import it in lantz/init.py it is not re-exported. |
I tried to troubleshoot this strange import behaviour, but was not too successful, sorry. I did not find out why the What is confusing is that I can do this:
so this looks ~ as expected, in that a module
fails as before. However, a potentially better workaround than lantzproject/lantz-drivers@52edaaf could maybe be, as you suggested, to promote InstrumentError to the lantz root, this would make usage less verbose/more straightforward, no? |
My gut feeling says that (import) usage should be fully exchangeable between namespace and non-namespace packages, so I feel like what we see here indicates some problem with the namespace setup, but I can't find out what's wrong. Seeing as you only support high Python 3 versions, have you ever considered going with native namespace packages instead of the pkgutil option? |
Happy new year! I actually use a combination fo both native namepsace packages and pkgutil. Because, AFAIK, it is not possible to have root package and subpackages. In other words, it is not possible to have lantz AND lantz.core, lantz.sims. I needed to add the pkgutil option for this reason. The following code in import sys
from lantz.core import errors, log
sys.modules['lantz.log'] = log
sys.modules['lantz.errors'] = errors In any case, I do think that By the way, I have published the package on pypi as lantzdev. See https://github.com/lantzproject/lantz for more info. Also I have added a examples repo: https://github.com/lantzproject/examples |
To you, too! Yeah, I've seen that. I hope that this will be re-integrated into vanilla lantz (on pypi too) as soon as you have consolidated the way to go forward with lantz. I would not worry too much about getting consensus out of the very scattered community, seeing as vanilla lantz is basically dead, I think continuing/restarting development there would be the most logical approach. |
I will try to assemble a minimal example and post it in stackoverflow. Regarding moving lantz forward. I think that having all individual packages (lantz-X) in PyPI and also the umbrella package ( Until now, the installation is really simple and straight forward. I have no seen any drawbacks (apart from these import glitches). In any case, these glitches are allowing me to think that needs to be exposed and what does not. Compartamentalization is a good thing and many things that I have recently added (logging capabilities backend/frontend, connect_feat in frontend, etc) arise from this. Also development in subpackages is working, at least for me. My proposal is: let's move this repo forward. I would be happy to incorporate the new drivers that have been developed and receive feedback and PR here. |
Just installed lantz with pyvisa-py,
lantz sims fungen tcp
is working but thenlantz qtdemo testpanel
faili can find error.py in lantz/core/ but dunno how to got further.
Thanks
The text was updated successfully, but these errors were encountered: