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

mb Python module's name can get into the way #69

Open
poeml opened this issue Jun 5, 2015 · 0 comments
Open

mb Python module's name can get into the way #69

poeml opened this issue Jun 5, 2015 · 0 comments
Labels

Comments

@poeml
Copy link
Owner

poeml commented Jun 5, 2015

                                                                                   [          ]

Issue migrated (2015-06-05) from old issue tracker http://mirrorbrain.org/issues/issue69

Title    mb Python module's name can get into the way
 Priority   bug         Status     chatting
Superseder            Nosy List    fukawi2, poeml
Assigned To poeml      Keywords    Packaging

msg264 (view) Author: poeml Date: 2010-09-19.01:13:25

The Python module's name "mb" can get into the way when it is being installed,
because it has the same name as the script "mb" / "mb.py".

This can lead to a very puzzling problem: Imports fail for mysterious reasons. I
have wasted a lot of time into debugging this pitfall in the past (in other
situations).

The issue is that the script "mb.py" imports the module named "mb", which leads to
importing itself instead of the module. This seems to happen when the script exists
with its ending ".py". The current directory is always the first in the search path
in Python, that's why.

This can be very hard to find out (as I learnt the hard way).

https://bbs.archlinux.org/viewtopic.php?pid=825860

Maybe the script should be named mb-commandline.py instead; when packaging it, a
link named "mb" could be added.

The only other solution (I think) would be to rename the module (e.g. to Mb).

msg265 (view) Author: poeml Date: 2010-09-19.01:17:02

Just a note, starting such a script with "python -v" as interpreter would display
all imported files, which can elucidate this problem.

History
         Date         User  Action        Args
2010-09-19 01:17:03 poeml set    messages: + msg265
2010-09-19 01:13:25 poeml create

(end of migrated issue)
@poeml poeml added the bug label Jun 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant