3

I have an isolated Wintel host not able to pip or etc, which equals to have network opened to 'internet'.
I downloaded python embedded form python.org (on other machine), copied and unzipped it to O:\xip\Python on isolated machine.
Now it looks like:

libcrypto-1_1.dll
libffi-7.dll
libssl-1_1.dll
LICENSE.txt
pyexpat.pyd
python.cat
python.exe
python3.dll
python38.dll
python38.zip
python38._pth
pythonw.exe
select.pyd
sqlite3.dll
unicodedata.pyd
vcruntime140.dll
winsound.pyd
_asyncio.pyd
_bz2.pyd
_ctypes.pyd
_decimal.pyd
_elementtree.pyd
_hashlib.pyd
_lzma.pyd
_msi.pyd
_multiprocessing.pyd
_overlapped.pyd
_queue.pyd
_socket.pyd
_sqlite3.pyd
_ssl.pyd

i have PyPI requests package, did python setup.py install it on other machine and i copied \build\lib\ directory (which appears) into isolated machine O:\xip\Python\build\lib\requests\
my PATH have O:\xip\Python;O:\xip\Python\build\lib
my PYTHONPATH have O:\xip\Python\python38.zip;O:\xip\Python\build\lib;O:\xip\Python\build\lib\requests
When i go to python console and run import requests i get no module named 'requests'

1. Should I unzip this python38.zip?
2. should i have something more in PATH or PYTHONPATH?
3. Should i copy something more from machine where i did install of request package?
Any ideas what is wrong here?

asked Feb 25, 2020 at 11:56
3
  • python setup.py install it on other machine - why didn't you do this in your target machine? You didn't use pip in this command. (Also, if you had pip, you can install local wheels, you don't have to access the internet.) Commented Feb 25, 2020 at 12:04
  • @h4z3 because i get no module setuptools Commented Feb 25, 2020 at 12:05
  • Okay. So another suggestion is: check your path and pythonpath on the originals system the package is from Commented Feb 25, 2020 at 12:09

2 Answers 2

2

The embedded distribution does not use environment vars. See here: Python Issue 28245

You should edit the python._pth file and put your additional paths there.

Alternatively, you could also extend sys.path before attempting the import.

answered Feb 25, 2020 at 12:13
Sign up to request clarification or add additional context in comments.

4 Comments

ok added path to libs but now with import requests attempt i get: ModuleNotFoundError: No module named 'urllib3'
I would guess that requests depends on urllib3. If it works on your "Build" system, you should be able to find and copy urllib3 from somewhere there.
On your Build machine, you can use pip install --install-option="--prefix=/some/path" requests --ignore-installed to have pip resolve all dependencies for you. See here stackoverflow.com/questions/2915471/…
python._pth was the core of my problems alongside all dependencies which modules need. Now i just copy installed modules with all dependand modules and all works fine! thanks
0

The embed.zip Windows Python distribution requires some tweaks. It does not run correctly "out of the box". I created a PowerShell script, PythonEmbed4Win.ps1, to install the embed.zip Python distribution downloaded from the Internet, and then tweak the installation so it will run without errors. The script will modify python._pth among other files.

Invoke-WebRequest -Uri "https://raw.githubusercontent.com/jtmoon79/PythonEmbed4Win/main/PythonEmbed4Win.ps1" -OutFile "PythonEmbed4Win.ps1"
.\PythonEmbed4Win.ps1 -Version 3.8

I have an isolated Wintel host not able to pip or etc

Run .\PythonEmbed4Win.ps1 on a host with Internet access then zip the contents and then transfer and unzip on your isolated host.

answered Nov 27, 2023 at 23:53

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.