Python Package Creation Example On 2022BFeb23 by David4ColeCanada@gmail.com Image: home/pi/Pictures/Python-Packages.jpg 1. Create a directory and name it Cars [all the following modules will be placed in this dir.] 2. Then create the first 3 modules. [Create the file named Bmw.py] #Bmw.py in Cars # Python code to illustrate the Modules class Bmw: # First we create a constructor for this class # and add members to it, here models def __init__(self): self.models = ['i8', 'x1', 'x5', 'x6'] #def end # A normal print function def outModels(self): print('These are the available models for BMW') for model in self.models: print('\t%s ' % model) #for end #def end #class end #Audi.py in Cars # Python code to illustrate the Module class Audi: # First we create a constructor for this class # and add members to it, here models def __init__(self): self.models = ['q7', 'a6', 'a8', 'a3'] #def end # A normal print function def outModels(self): print('These are the available models for Audi') for model in self.models: print('\t%s ' % model) #for end #def end def outModel_a8(self): print('These are the available models for Audi') for model in self.models: if model=='a8': print('\t%s ' % model ) #if end #for end #def end #class end #Nissan.py in Cars # Python code to illustrate the Module class Nissan: # First we create a constructor for this class # and add members to it, here models def __init__(self): self.models = ['altima', '370z', 'cube', 'rogue'] #def end # A normal print function def outModels(self): print('These are the available models for Nissan') for model in self.models: print('\t%s ' % model) #for end #class end #__init__.py in Cars (can be empty) from Bmw import Bmw from Audi import Audi from Nissan import Nissan #sample.py # Import classes from your brand new package from Cars import Bmw from Cars import Audi from Cars import Nissan # Create an object of Bmw class & call its method ModBMW = Bmw() ModBMW.outModels() # Create an object of Audi class & call its method ModAudi = Audi() ModAudi.outModels() # Create an object of Nissan class & call its method ModNissan = Nissan() ModNissan.outModels() #getbuyProgram.py #from Cars.Audi.a8 import get_buy #Now call the function from anywhere: get_buy(1) print("end of getbuyProgram.py") #end of getbuyProgram.py Source: Thonny Packages Title: This worked for Thonny as of 2022BFeb23 I am still modifying it replacing Cars with IX Thonny uses its own virtual environment by default. Open "Tools => Manage packages" or "Tools => Open system shell" in order to install into this environment. For completeness I will add that once you are in the Thonny System Shell you can run either "pip" or "pip3" to install the module you need. 1. Tell Thonny to include the Tools menu 2. Restart Thonny, then click on "Tools" 3. Select "Manage Packages" 4. Read "Target: user site packages from /home/pi/.local/lib/python3.7/site-packages This dialog lists all available packages, but allows upgrading and uninstalling only packages from /home/pi/.local/lib/python3.7/site-packages . New packages will be also installed into this directory. Other locations must be managed by alternative means. Source:https://www.youtube.com/watch?v=Oo-B98WWre8 Title: Thonny: The Beginner-Friendly Python Editor By Krishelle hardson-Hurley Source: http://geeksforgeeks.org/create-access-python-package Title: Create and Access a Python Package By Chinmoy Lenka On 15 Feb, 2018 NB This doesn't work for Thonny /PythonPackageCreation.txt