Replies: 1 comment
-
@zeyuwang615 PEX files are intended to be the equivalent of a hermetic, fully self-contained virtualenv. By default a PEX purposely ignores all packages on your system and just uses the Python interpreters found there. To ask PEX to not be hermetic, you must use For example, given this $ cat example.py
import colors
import cowsay
print(colors.green(cowsay.get_output_string("tux", "Hello Venv!"))) And this PEX with missing deps (no
You get:
Here I set up a venv with the missing dep, which it sounds like you did:
And here I tell PEX it's ok to let the outside environment leak in:
And that penguin is, in fact, green! All that said, this is generally not what you want to do! You should try to build the PEX file to contain the dependencies needed for each interpreter / platform it will be run on. See |
Beta Was this translation helpful? Give feedback.
-
Hi, there!
I am trying to run a packed python .pex file with the command
./xxx.pex main.py
. However, I just discover that there are a few necessary packages missing in the pex file. So I try to specify the custom python interpreter in a virtualenv with all the necessary packages with thePEX_PYTHON
environment variable. Strangely,PEX_PYTHON=/path/to/venv/python ./xxx.pex main.py
does not work, and so does/path/to/venv/python ./xxx.pex main.py
. I wonder how I can specify the python environment or add the necessary packages without needing to regenerate or change the .pex file?Thanks a lot!
Beta Was this translation helpful? Give feedback.
All reactions