I am attempting to create a PEX file of a simple 3 page flask website. The website works with Gunicorn on python3, the client wants the site compiled to a encapsulated pex file.
pex -r zb1/requirements.txt -e zb1/run -o zb1.pex
also tried
pex -r zb1/requirements.txt -m zb1:run -o zb1.pex
When I run that command it compiles just fine but the trouble is when I attempt to run a pex file.
c:~ c$ ./zb1.pex 
Traceback (most recent call last):
  File ".bootstrap/_pex/pex.py", line 326, in execute
  File ".bootstrap/_pex/pex.py", line 258, in _wrap_coverage
  File ".bootstrap/_pex/pex.py", line 290, in _wrap_profiling
  File ".bootstrap/_pex/pex.py", line 369, in _execute
  File ".bootstrap/_pex/pex.py", line 427, in execute_entry
  File ".bootstrap/_pex/pex.py", line 432, in execute_module
  File "/usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 192, in run_module
    mod_name, mod_spec, code = _get_module_details(mod_name)
  File "/usr/local/Cellar/python3/3.5.2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 127, in _get_module_details
    raise error("No module named %s" % mod_name)
ImportError: No module named zb1/run
I have tried different variations of the pex commands. This is on MacOSX El Capitan with python2.7 and python3.5 
Thank you in advance and let me know if you need any extra information.
Project Structure
zb1
├── README.md
├── __init__.py
├── application
│   ├── config.py
│   ├── static
│   ├── templates
│   ├── uploads
│   ├── utilities
│   └── zbo
├── buildup.py
├── env
├── requirements.txt
├── run.py  << ENTRY POINT!
└── setup.sh
				
                        
The commands you are running are only including the requirements for your project, they don't actually instruct Pex to include your code. To get your code inside the Pex executable you need to first package it and then instruct Pex to include that package.
(for whatever reason Pex did not like the name
zb1so I usedmypackageinstead)1. Package your code:
Create a
setup.pyfile at the top level:Move your code to a subdirectory with the same name as your package:
Create a wheel file:
This will create a file with all of your code named
mypackage-1.0.0-py3-none-any.whl2. Run Pex including your package:
Note that the executable is specified using a dot between the package and module.