我正在使用Python 3.6.7运行Windows 10。
一段时间以来,我一直在尝试使用PEX,但我什至无法通过最基本的任务,即创建一个带有简单脚本的包,上面写着“ Hello world”。
我有一个目录,里面只有一个文件__main__.py
,里面是:
print('Hello world!')
当我尝试使用在同一目录中启动的pex -o hello.pex
构建一个PEX软件包时,我得到的是:
File "C:\Program Files\Python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Program Files\Python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "__main__.py", line 23, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File ".bootstrap\pex\third_party\__init__.py", line 430, in <module>
File ".bootstrap\pex\third_party\__init__.py", line 407, in install
File ".bootstrap\pex\third_party\__init__.py", line 205, in install_vendored
File ".bootstrap\pex\third_party\__init__.py", line 255, in install
File ".bootstrap\pex\third_party\__init__.py", line 153, in _iter_importables
File ".bootstrap\pex\third_party\__init__.py", line 108, in iter_root_modules
File ".bootstrap\pex\third_party\__init__.py", line 119, in _filter_names
File "C:\Program Files\Python36\lib\re.py", line 233, in compile
return _compile(pattern, flags)
File "C:\Program Files\Python36\lib\re.py", line 301, in _compile
p = sre_compile.compile(pattern, flags)
File "C:\Program Files\Python36\lib\sre_compile.py", line 562, in compile
p = sre_parse.parse(p, flags)
File "C:\Program Files\Python36\lib\sre_parse.py", line 855, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
File "C:\Program Files\Python36\lib\sre_parse.py", line 416, in _parse_sub
not nested and not items))
File "C:\Program Files\Python36\lib\sre_parse.py", line 502, in _parse
code = _escape(source, this, state)
File "C:\Program Files\Python36\lib\sre_parse.py", line 401, in _escape
raise source.error("bad escape %s" % escape, len(escape))
sre_constants.error: bad escape \p at position 11
我也尝试按照该教程https://gist.github.com/simeonf/062af826e79259bc7686进行操作,但是遇到同样的问题。总的来说,我很难找到可以工作的PEX 101,所以在这里我有点迷路。
在我的示例中,我仅使用该脚本,但没有virtualenv,设置工具或类似工具。 有人可以给我一些指导吗?