Python Forum
start interactive pyhton shell with pre-loaded custom modules
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
start interactive pyhton shell with pre-loaded custom modules
#1
Hi all,
I'm a beginner & giving myself a few simple projects to try to find stuff out. I'm trying to make a sort of desktop calculator in the form of a interactive python shell with some modules already loaded so i can just press a shortcut and go.
OS: kubuntu 18.04
python 3.6.9
#!/usr/bin/env python3

# import some modules
import math
import compound_interest
import check_prime


# Go to interactive mode
import code
#code.interact(local=locals())
the build-in module math works, but the self-mades ones don't (see error below). also, i'd like to suppress the version information that's printed when switching to interactive.
Error:
TypeError: 'module' object is not callable
Thanks for any help
Reply
#2
Show us your modules, because it's working.

a.py

def a():
    print("hello")
main.py

import a
import code

>>> a.a()
hello
Reply
#3
Thank you for replying.
It was indeed in the modules. I wrote them first as little programs and didn't realise i needed to remove the "#!/usr/bin/...".
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Vlookup function in Pyhton antozas 1 590 Oct-02-2023, 04:16 AM
Last Post: vikraman
  Interactive plots that can be embed in web page mouse9095 1 571 Jun-12-2023, 04:51 PM
Last Post: deanhystad
  Is Matplotlib.pyplot Loaded DaveG 2 1,276 Apr-06-2022, 06:12 AM
Last Post: DaveG
  Package cannot be loaded into PBS queue file emersonpl 1 1,777 Sep-09-2021, 08:06 PM
Last Post: emersonpl
  PyQt5 MySQL Drivers Not Loaded AdeS 7 4,940 Aug-06-2021, 08:34 AM
Last Post: AdeS
  Reading Multiple text Files in pyhton Fatim 1 1,886 Jun-25-2021, 01:37 PM
Last Post: deanhystad
  MacOS BigSur Python3 - dyld: Library not loaded: trillionanswers 1 4,167 Mar-02-2021, 11:00 PM
Last Post: nilamo
  Why is mpl_toolkits loaded? Gribouillis 1 1,565 Jan-30-2021, 08:39 PM
Last Post: Serafim
  interactive map and function hurc60248 1 1,722 Jan-08-2021, 09:22 PM
Last Post: Larz60+
  Pyhton code help from head first with python Shaikat_99 3 3,102 Jun-07-2020, 09:12 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

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