Python Forum
Python script with local libraries
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python script with local libraries
#1
Hello. I would like to get advise on how to properly create and manage a project with local libraries. For example, I am creating a script that uses mysql.connector library that I have downloaded using pip on my machine. Now imagine someone downloads my program ( .py script as well as Library folder) but he does not have mysql.connector library installed, I would still expect my program to work because It would look for the library locally.

I use Thonny for my programming IDE but I have changed the default interpretter. Instead of using the Thonny Interpreter I use Python 3.10 that I have downloaded from official Python website.

The project structure should be as following:
https://ibb.co/HztxzcB

Could someone clarify how do I exactly import local libraries in my folder and how do I prevent from using the global libraries? If user has installed mysql.connector on his PC, I would still want to use my local library instead of his version because the versions may differ.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Bug Python 3.12 cannot import local python files as modules sunflowerdog 25 19,709 Jul-31-2024, 01:52 PM
Last Post: sunflowerdog
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 8,146 Jun-29-2023, 11:57 AM
Last Post: gologica
  Adding libraries to embedded Python as a ZIP The_Oman 0 2,144 May-05-2023, 04:05 PM
Last Post: The_Oman
  How to create local copies of Python packages so they do not have to be downloaded okhajut 3 3,617 Sep-29-2020, 02:22 PM
Last Post: buran
  How to kill a bash script running as root from a python script? jc_lafleur 4 8,031 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 2,998 May-28-2020, 05:27 PM
Last Post: micseydel
  Installing Python and pointing it to required libraries hooiberg 2 5,530 May-13-2019, 05:55 PM
Last Post: ebolisa
  Package python script which has different libraries as a single executable or script tej7gandhi 1 3,254 May-11-2019, 08:12 PM
Last Post: keames
  python 'SMTP debugging server' not starting local error pcsailor 1 4,401 Nov-26-2018, 10:13 PM
Last Post: micseydel
  Python debugging local os Baggelhsk95 1 2,776 Oct-18-2018, 10:11 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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