--preamble runpy path error
See original GitHub issueI believe this may be an issue on linux machines… but when trying to copy the cleanup example posted in PR #156 exactly, and running with the require flags:
... --preamble shiv_cleanup.py ...
I get the error:
Traceback (most recent call last):
File "envs/python38/lib/python3.8/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "envs/python38/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "./mpro/__main__.py", line 3, in <module>
File "./mpro/_bootstrap/__init__.py", line 219, in bootstrap
File "envs/python38/lib/python3.8/runpy.py", line 262, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "envs/python38/lib/python3.8/runpy.py", line 232, in _get_code_from_file
with io.open_code(fname) as f:
TypeError: open_code() argument 'path' must be str, not PosixPath
Looks like this is because runpy doesn’t support Path objects? Its failing on 232:
230 def _get_code_from_file(run_name, fname):
231 # Check for a compiled file first
232 with io.open_code(fname) as f:
233 code = read_code(f)
234 if code is None:
235 # That didn't work, so try it as normal source code
236 with io.open_code(fname) as f:
237 code = compile(f.read(), fname, 'exec')
238 return code, fname
As a near term fix, should this pathobj be converted to a string?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
runpy — Locating and executing Python modules — Python ...
The runpy module is used to locate and run Python modules without importing them first. Its main use is to implement the -m...
Read more >Could not import runpy module - python - Stack Overflow
So, I append my python's library path to the configuration(don't ... Had the same "Could not import runpy module" error, but in Windows....
Read more >Changelog - ActivePython 3.6.6 Documentation
Exit with error in case that invalid parameters are specified to ... to “python -m” or runpy.run_module() is found in sys.modules after parent...
Read more >Misc/HISTORY - external/github.com/python/cpython
Issue #19456: ntpath.join() now joins relative paths correctly when a drive ... Issue #14439: Python now prints the traceback on runpy failure at...
Read more >History - setuptools 65.6.3.post20221216 documentation
unescape is deprecated and will be removed in Python 3.9. #1790: Added the file path to the error message when a UnicodeDecodeError occurs...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hey @Alex-Mann,
I’ve actually observed this too, on Python 3.8.2 on macOS:
I’d happily ship an RB string-ifying those inputs 😃
After studying the problem, I found a very simple, one-line fix. PR #196 implements the changes. This makes shiv-produced zipapps work on my version of the Apple-provided Python 3.8 on macOS 10.14 and macOS 11.1 (where I’ve tested so far).
Would the maintainers of
shiv
please consider incorporating this change?