Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
module not found, is ok?
#1
I created a own __init__.py which call in a script.
Works just fine.

However, I renamed a module (all to lowercase), so a script obviously doesn't find the module.

Which raised the question, do you try to catch this error? o
import mymodule
if mymodule.MyFunc:
       # MyFunc doesn't exist. myfunc does
or is this a case of 'you have to code correct'?
Reply
#2
We are not python.org and are not involved in python language development, however:

I don't believe that python would check for this type of error.

Python would have to know your complete code tree to do so, and this would encompass so many variations as to be impracticable.
Reply
#3
Oh I'm no professional programmer and this is only used for my firm.

So no other users, not even other programmers who use it. So obviously I fix my uppercase issue, but I was wondering in general if it was 'catchable'.

Smile
Reply
#4
You can catch the error, but what would you do once caught? Would you try some other type of import?

The only time I've seen that technique is if you have some optional feature available through a module. You can import the feature and if the import fails, not make that option available.

But if the module is required, failing on the import is expected.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pyside6 module not found ForeverNoob 4 1,268 Aug-18-2023, 04:36 PM
Last Post: snippsat
  Module Not Found Error bitoded 4 1,343 Jan-01-2023, 09:08 AM
Last Post: bitoded
  pdfminer package: module isn't found Pavel_47 25 8,394 Sep-18-2022, 08:40 PM
Last Post: Larz60+
  Module not found question sighhhh12 0 1,446 Sep-09-2022, 05:43 AM
Last Post: sighhhh12
  [SOLVED] Tkinter module not found Milan 7 21,409 Aug-05-2022, 09:45 PM
Last Post: woooee
  No module found when I run a main.py tomtom 2 1,410 Jul-20-2022, 09:24 AM
Last Post: tomtom
  No Module found in other directory than source code [SOLVED] AlphaInc 1 2,004 Nov-10-2021, 04:34 PM
Last Post: AlphaInc
  KafkaUtils module not found on spark 3 pyspark aupres 2 7,256 Feb-17-2021, 09:40 AM
Last Post: Larz60+
  'urllib3' Module not found when import 'requests' spanz 5 9,954 Jan-06-2021, 05:57 PM
Last Post: snippsat
  no module named finbert found ErnestTBass 4 4,483 Dec-05-2020, 06:09 PM
Last Post: andrianas

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020