Python Forum
package script cant find sibling script when executed from outside
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
package script cant find sibling script when executed from outside
#1
Hello together,
i just finished my first own package but facing a problem when importing and executing things from outside:
I made a very minimal example as demonstration:

Folder "mymodule" contains:
#__init__.py
# empty

#constants.py
my_const = 42

#function.py
def my_func():
       print(my_const)
On the same level as mymodule is :
# test.py
from mymodule.function import my_func
my_func()
Unfortunately i get the error message: "no module named 'constant' " which confuses me since i can import constant in function.py properly.

Question: Why is that? ( Maybe this code should that never be necessary - let me know anything you have in mind :)

Thank you very much,
Bock

PS: how can i make a "tab" in the python brackets of the thread editor?
Reply


Messages In This Thread
package script cant find sibling script when executed from outside - by Bock - Mar-03-2023, 11:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  total Noob question: Why is the code not executed MarkMan 5 651 May-09-2025, 06:15 PM
Last Post: deanhystad
  MPEG DASH Package implementation similar to M3U8 package anantha_narayanan 1 971 May-05-2025, 08:34 AM
Last Post: pintailscratchy
  Running script from remote to server invisiblemind 4 952 Mar-28-2025, 07:57 AM
Last Post: buran
  Insert command line in script lif 4 1,359 Mar-24-2025, 10:30 PM
Last Post: lif
  modifying a script mackconsult 1 697 Mar-17-2025, 04:13 PM
Last Post: snippsat
  help with a script that adds docstrings and type hints to other scripts rickbunk 1 1,403 Feb-24-2025, 05:12 AM
Last Post: from1991
  Detect if another copy of a script is running from within the script gw1500se 4 1,303 Jan-31-2025, 11:30 PM
Last Post: Skaperen
  pass arguments from bat file to pyhon script from application absolut 2 1,518 Jan-13-2025, 11:05 AM
Last Post: DeaD_EyE
  Best way to feed python script of a file absolut 6 1,445 Jan-11-2025, 07:03 AM
Last Post: Gribouillis
  How to make it so whatever I input into a script gets outputted on a different file spermatozwario 4 1,359 Nov-24-2024, 12:58 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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