python
python copied to clipboard
ImportError while doing exercise
Hi all!
I hope this forum is the right place to put bugs.
I am doing excersise 2 (Lasagna) from Python and I get an import error, see below. I do not think I made a mistake with programming, because I have also looked at the solutions from the community and when I enter the exact same solution, it gives the same error. Now I cannot continue.
So how can this problem be fixed? Thank you very much!
" We received the following error when we ran your code:
ImportError while importing test module '.mnt.exercism-iteration.lasagna_test.py'.
Hint: make sure your test modules.packages have valid Python names.
Traceback:
.mnt.exercism-iteration.lasagna_test.py:6: in
During handling of the above exception, another exception occurred:
.usr.local.lib.python3.10.importlib.init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
.mnt.exercism-iteration.lasagna_test.py:23: in
Hi and welcome to Exercism! :wave:
Thanks for opening an issue :slightly_smiling_face:
- If you are suggesting a new feature or an improvement to Exercism, please take a read of this post, which will likely result in a faster response.
- If you are reporting a bug in the website, thank you! We are getting a lot of reports at the moment (which is great), but we triage and reply as soon as we can.
- If you are requesting support, someone will help shortly.
- For everything else, we will reply or triage your issue to the right repository soon.
Hi @LindaK92 👋🏽
Thanks for filing this issue. As the Python track maintainer, i'd like to apologize -- that is bad logic in the test file, resulting in a bogus error message. We're using the logic for a missing function name, but it needs to be doing something different here. We'll try to get that bug fixed as quickly as we can.
However - mixed up in that erroneous message is a legitimate problem telling you that the test runner cannot import a name that it needs. It sadly happens to be lying about what kind of name it is trying to import. 🤦🏽♀️
The tests are looking for a constant named EXPECTED_BAKE_TIME, defined (usually) at the top of the file like so:
EXPECTED_BAKE_TIME = <replace with some numeric value you fill in here>
PREPARATION_TIME = <replace with some other numeric value you fill in here>
def bake_time_remaining(time):
return <replace with code that uses the constants here>
def preparation_time_in_minutes(num_layers):
return <replace with more code you fill in here>
For the quick test I did in my account on the website, if I don't have that first line defining the constant, I get the same stack trace you do. I think if you define (and use) that missing constant, the test runner will stop complaining.
Please let me know if that is not the case, and I'll try to help you further with getting unstuck (or help identify any additional bugs).
Again - apologies for the lying test runner. 😉
@iHiD or @ErikSchierboom -- could one of you transfer this to the python repo? Many thanks!
🤖 🤖
Hi! 👋🏽 👋 Welcome to the Exercism Python Repo!
Thank you for opening an issue! 🐍 🌈 ✨
- If you are requesting support, we will be along shortly to help. (generally within 72 hours, often more quickly).
- Found a problem with tests, exercises or something else?? 🎉
◦ We'll take a look as soon as we can & identify what work is needed to fix it. (generally within 72 hours).
◦ If you'd also like to make a PR to fix the issue, please have a quick look at the Pull Requests doc.
We 💙 PRs that follow our Exercism & Track contributing guidelines!
- Here because of an obvious (and small set of) spelling, grammar, or punctuation issues with one exercise,
concept, or Python document?? 🌟Please feel free to submit a PR, linking to this issue.🎉
‼️ Please Do Not ‼️ ❗ Run checks on the whole repo & submit a bunch of PRs. ...These sorts of things are not considered helpful, and will likely be closed by reviewers. |
- For anything complicated or ambiguous, let's discuss things -- we will likely welcome a PR from you.
- Here to suggest a feature or new exercise?? Hooray! Please keep in mind Chesterton's Fence.
Thoughtful suggestions will likely result faster & more enthusiastic responses from maintainers.
💛 💙 While you are here... If you decide to help out with other open issues, you have our gratitude 🙌 🙌🏽.
Anything tagged with [help wanted] and without [Claimed] is up for grabs.
Comment on the issue and we will reserve it for you. 🌈 ✨
I did the Hello_world test and encountered an error on submission as seen below. Kindly assist.
We received the following error when we ran your code: ImportError while importing test module '.mnt.exercism-iteration.hello_world_test.py'. Hint: make sure your test modules.packages have valid Python names. Traceback: .usr.local.lib.python3.10.importlib.init.py:126: in import_module return _bootstrap._gcd_import(name[level:], package, level) .mnt.exercism-iteration.hello_world_test.py:3: in from hello_world import ( E ImportError: cannot import name 'hello' from 'hello_world' (.mnt.exercism-iteration.hello_world.py)
Hi @bo1658a 👋🏽
As stated in the auto-response for the last issue you opened on this repo, we would prefer if you first raised issues in our exercism forum, and not here in the Python repo.
The forum has many friendly people who would love to discuss and help students with issues they encounter. Another alternative is to use our CLI to upload your partial solution and request mentoring. A mentor can walk through your solution and point out where things might have gone wrong.
My reply in this forum post might also be helpful for you.
In the future, please don't comment on an unrelated exercise (this issue is in regards to Guido's Gorgeous Lasagna and not Hello World), as it creates confusion and noise.
Many thanks, and good luck with the exercise.
@ErikSchierboom or @iHiD - any chance I could get eyes/approvals for the following related issues?
I know it won't fix Hello World, but I do think it would help with the complaints we're getting on Lasagna.
Many thanks!
#3339, #3344, and python-test-runner #110.
Done