Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
check imports
#1
I have an import statement

from Jets.Analysis.Plot import *
I suspect the imports did not run well as when I call
Plot()
a loop has an unexpected jump to beginning and the same happens if I write
Pllott()
How can I test if the import was successful and diagnose problems?
Reply
#2
Might be easier for people to diagnose your problem if you post a bit more code. However, in general if you import something and it doesn't error than the import is working properly. That being said I could not find any modules called jet; is this a module that you wrote?
Reply
#3
yes, that is a custom made module.
But the problem was found in not invoking Plot() with the proper arguments. Python did not supply any error statements.
Reply
#4
Regarding 'star import'. Documentation >>> The Python Tutorial >>> 6. Modules

Quote:There is even a variant to import all names that a module defines:

>>> from fibo import *
>>> fib(500)
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377
This imports all names except those beginning with an underscore (_). In most cases Python programmers do not use this facility since it introduces an unknown set of names into the interpreter, possibly hiding some things you have already defined.

Note that in general the practice of importing * from a module or package is frowned upon, since it often causes poorly readable code. However, it is okay to use it to save typing in interactive sessions.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#5
(Jul-26-2018, 09:19 PM)Viesturs Wrote: yes, that is a custom made module.
But the problem was found in not invoking Plot() with the proper arguments. Python did not supply any error statements.
It's a problem with your custom made module, not python. Probably there is poor error handling - i.e. it looks like it catch and ignore/pass all/most exceptions.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
When I call:

from Jets.Analysis.Plot import *
how can I check the path to the module Plot.py

I need this to set a gdb breakpoint in Plot.py.

What environment variables does python use to search for the module Plot.py? How can I check this variable?

The source in Plot.py is imported via a link, which makes matters somewhat more complicated.
Reply
#7
(Jul-27-2018, 01:32 PM)Viesturs Wrote: how can I check the path to the module Plot.py

What environment variables does python use to search for the module Plot.py? How can I check this variable?

I would like to point out following pieces of Python documentation:

Documentation >>> The Python Language Reference >>> 7. Simple statements >>> 7.11. The Import statement

Documentation >>> The Python Language Reference >>> 5. The import system

Documentation >>> Python Frequently Asked Questions >>> Programming FAQ >>> Core language >>> What are the "best practices" of using import in a module

Documentation >>> The Python Tutorial >>> Modules

With high probability you can find answers to your questions there and plenty of information how import works in Python.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Imports that work with Python 3.8 fail with 3.9 and 3.10 4slam 1 2,550 Mar-11-2022, 01:50 PM
Last Post: snippsat
  Imports in my first package cuppajoeman 1 1,912 Jun-28-2021, 09:06 AM
Last Post: snippsat
  script with imports works but pytest gives "ModuleNotFoundError"? Hpao 0 1,544 Jun-27-2021, 08:30 PM
Last Post: Hpao
  Help wanted with python imports petros21 3 2,481 Apr-07-2021, 07:16 PM
Last Post: snippsat
Question How to include Modules not found (conditional imports) in my setup.py when I want to cff 0 3,765 Mar-17-2021, 11:57 AM
Last Post: cff
  threading across imports Nickd12 2 2,104 Nov-09-2020, 01:59 AM
Last Post: Nickd12
  refreshing imports seandepagnier 4 2,674 Sep-20-2020, 11:51 PM
Last Post: seandepagnier
  Multimode imports fine as script but not after compiling into exe chesschaser 0 2,372 Aug-13-2020, 01:28 PM
Last Post: chesschaser
  absolute imports between folders mikisDW 0 1,505 Aug-05-2020, 12:26 PM
Last Post: mikisDW
  Understanding the concept ( Modules , imports ) erfanakbari1 1 2,140 Nov-25-2019, 01:59 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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