Home:ALL Converter>Unable to fully package my Python script with all the modules and dependencies it needs for Linux

Unable to fully package my Python script with all the modules and dependencies it needs for Linux

Ask Time:2019-10-24T17:20:58         Author:rogaloo

Json Formatter

I have a Python 2.7 script that uses BeautifulSoup4 and requests modules.

The issue is, that I need to deploy this script on a machine to which we can not directly install any new modules/libaries via pip install or anything else. We can copy this script and any files it needs to run to that machine, but we can not directly install any modules.

I have tried PyInstaller, PEX and Nuitka to create an executable file or a bundle (in any format, for example .zip) so that we can copy the entire file or bundle into the machine and run the python script from there, without the need to do pip install or installing the modules manually via Wheel file. All without success.

Environment details: Target machine on which the script needs to run: RHEL-based Linux OS with Python 2.7. My development machine: Windows 10 but I also have access to Fedora Linux machine both with Python 3 and Python 2.7.

The import section of my script looks like this:

from __future__ import with_statement from __future__ import absolute_import import requests import re from bs4 import BeautifulSoup from io import open

Can someone, please, help me out here? We have the script ready to be deployed, but we are not able to run it in our target machine because of the missing modules/libraries.

Thank you very much

EDIT: Mentioning this since it may not be clear at first - we do not have the issue with a network connection or anything of this gender. We were prohibited to use pip install or a manual method of installing a module. Therefore, we can only bundle the modules directly with the script or something so that would not need to directly install the modules on the target machine itself.

Author:rogaloo,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/58538158/unable-to-fully-package-my-python-script-with-all-the-modules-and-dependencies-i
yy