How to enable third-party modules with my python scripts?

I started using Python to automate the repetitive tasks that I have at work, and often I need to integrate links to third-party modules into my scripts. How can I include these files with my scripts directly? I know that there are ways to install libraries centrally in my python installation folder (C: \ Python27). Many third-party modules provide an EXE installer that will do this automatically. However, I am concerned about how this will affect the portability of my scripts. For example, if I send my script to someone else, I also do not want to send them a list of all the individual modules that they need to download and install.


Update

I have a lot more experience with a C # project in Visual Studio. In a visual studio project, if I want to use a third-party DLL, I simply include this DLL in my solution in the Lib folder and refer to this DLL from my project. I don't want to load this library into the GAC, which seems to me like the .NET equivalent for installing the python package.

Is there any possibility, can I just include third-party libraries in my project folder and reference them using a relative path? Let's say I had the following file structure.

\My Script.py \lib\3rdPartyLib\3rdPartyLib.py 

Can I import 3rdPartyLib from MyScript.py?

 import 3rdPartyLib from \lib\3rdPartyLib\ ?????? 

Why don't I want to do this?

+4
source share
2 answers

Update:

Yes, you can copy third-party modules to your application folder. Using the site-packages folder, you can centralize updates for each machine, if you rarely change libraries, it may be easier for you to simply include them in your application folder, as you described.

If possible, placing application folders on a network drive will simplify network updates.


Do you want to use py2exe or pyinstaller .

It will build a folder full of dependencies, and Windows.exe. You can also include icons and other metadata. Wrap it in a free installer, such as innoSetup , and you will have a professional looking application at your fingertips.

+1
source

Well, you can use py2exe or pyinstaller, or you can reference your modules when running scripts, pack them in an archive, and transfer your program to other OSs! But so many hehe, I see that you only use windows! What makes you think about portability in your head ...

-1
source