I just build a jupyter-labs pex by making a requir...
# pex
I just build a jupyter-labs pex by making a requirements file from
pip freeze
then using that as the input to
pex -r /tmp/jupyterlab-requirements.txt -o jupyter-labs.pex -p /Users/myacct/.pyenv/shims/python
. When I go to run the pex with
jupyter-labs.pex -e jupyterlab.labapp:main
I get the following error:
Copy code
jupyter-labs.pex -e jupyterlab.labapp:main
Traceback (most recent call last):
  File "/Users/myacct/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 185, in _run_module_as_main
    mod_name, mod_spec, code = _get_main_module_details(_Error)
  File "/Users/myacct/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 219, in _get_main_module_details
    return _get_module_details(main_name)
  File "/Users/myacct/.pyenv/versions/3.6.9/lib/python3.6/runpy.py", line 128, in _get_module_details
    spec = importlib.util.find_spec(mod_name)
  File "/Users/myacct/.pyenv/versions/3.6.9/lib/python3.6/importlib/util.py", line 91, in find_spec
    return _find_spec(fullname, None)
  File "<frozen importlib._bootstrap>", line 894, in _find_spec
  File "<frozen importlib._bootstrap_external>", line 1157, in find_spec
  File "<frozen importlib._bootstrap_external>", line 1131, in _get_spec
  File "<frozen importlib._bootstrap_external>", line 1112, in _legacy_get_spec
  File "<frozen importlib._bootstrap>", line 441, in spec_from_loader
  File "<frozen importlib._bootstrap_external>", line 544, in spec_from_file_location
  File "/Users/myacct/dev/virtualenvs/tmp-bc02eb6e921a2fd/jupyter-labs.pex/__main__.py", line 3
    [ -n "$PYENV_DEBUG" ] && set -x
SyntaxError: invalid syntax
Am I missing something? I'm using a virtualenv to build the pex. I am also using
for my python interpreter.
When I set
to anything, I get debug information that begins with
I'm manually building this pex file to better understand how to code the
plugin I've been discussing in #plugins.
the code in question is shell code which Python is rejecting
as for why a
has shell code, that is unexpected
This is the
in the built pex.
right, but the first part of that script is a bash script, not a Python script. the Python interpreter will not parse bash.
👍🏽 1
Looks like it is something with the jupyter-lab setup. I just redid it with a
example and the
contains nothing but python in that pex.
Yes. I got that. Why it is putting it in there?
interesting, so the interaction of pex and jupyter-lab is doing something weird then
I think I may of found the problem.
doing a test...
found it. I had
-p /Users/myacct/.pyenv/shims/python
which is a bash script python shim.
user error
I'll update the question.
we potentially could have pex try to detect this case by flagging files passed to
that have a shebang line that is not python
👍🏽 1
Is this something
should error out on? If yes, I'll make an issue.
it is worth reporting. it may not be perfectly solvable but worth giving some thought to
I'll make an issue. At the worse it gets closed and we have a more permanent memory in github than this free slack.
👍 2
That's an easy mistake to make, but I don't see a fix there. The
docs are clear.
Yup. User error. 👁️ 👁️