

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How we can bundle multiple python modules?
Assuming you are using Python 2.6 or later, you could package the scripts into a zip file, add a __main__.py and run the zip file directly. For example, if you zip all files in a file called my_app.zip and place your main script in __main__.py, you can run this zip using python:
$ python my_app.zip
If you want to use a third party script, you can have a look at stickytape module. It can be used to convert a Python script and any Python modules it depends into a single-file Python script. To install stickytape, open your terminal and enter:
$ pip install stickytape
Assuming all your scripts and dependencies reside in the script/sample folder, you can use stickytape in the following way:
$ stickytape scripts/sample --add-python-path . > ./sample-standalone
You can also use the --output-file parameter to give it a file argument:
$ stickytape scripts/sample --add-python-path . --output-file ./sample-standalone
- Related Questions & Answers
- How we can import Python modules in Jython?
- How we can import Python modules without installing?
- Can we keep Python modules in compiled format?
- How we can copy Python modules from one system to another?
- Can we iteratively import python modules inside a for loop?
- How we can extend multiple Python classes in inheritance?
- How we can split Python class into multiple files?
- How can we print multiple blank lines in python?
- How to use multiple resource bundle in same JSP?
- How to use multiple modules with Python import Statement?
- How can we do Python operator overloading with multiple operands?
- How do we use easy_install to install Python modules?
- How can we display all modules with classloaders in Java 9?
- How we can break a string with multiple delimiters in Python?
- How can we combine multiple print statements per line in Python?
Advertisements