`pipx install` doesn't seem to work with `--python python3.4`
See original GitHub issueDescribe the bug
The pipx documentation states that the --python
flag can be used to specify Python versions 3.3 and up for running the code installed in a given pipx virtual environment. However there seems to be some sort of json decoder issue with this. My first glance at the output makes it look like it’s an error with Python type annotation.
How to reproduce
The environment I encountered this on is a CentOS 7 Linux computer. CentOS 7 repo’s provided Python 3.4 and I have manually installed Python 3.5, 3.6, and 3.7.
$ python3.7 -m pip install --user pipx
$ python3.7 -m pipx run --python python3.4 cowsay 'Hello, world!'
_____________
< Hello, world! >
=============
\
\
^__^
(oo)\_______
(__)\ )\/\
||----w |
|| ||
$ python3.7 -m pipx install --python python3.4 cowsay
File "<string>", line 89
app_paths_of_dependencies: Dict[str, List[str]] = {}
^
SyntaxError: invalid syntax
⢿ installing package 'cowsay'Traceback (most recent call last):
File "/home/bkboulton/.pyenv/versions/py37/bin/pipx", line 10, in <module>
sys.exit(cli())
File "/home/bkboulton/.pyenv/versions/py37/lib/python3.7/site-packages/pipx/main.py", line 547, in c
exit(run_pipx_command(parsed_pipx_args))
File "/home/bkboulton/.pyenv/versions/py37/lib/python3.7/site-packages/pipx/main.py", line 166, in r
include_dependencies=args.include_deps,
File "/home/bkboulton/.pyenv/versions/py37/lib/python3.7/site-packages/pipx/commands.py", line 318,
if venv.get_venv_metadata_for_package(package).package_version is None:
File "/home/bkboulton/.pyenv/versions/py37/lib/python3.7/site-packages/pipx/Venv.py", line 161, in g
self.python_path, VENV_METADATA_INSPECTOR, package, str(self.bin_path)
File "/home/bkboulton/.pyenv/versions/3.7.4/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/home/bkboulton/.pyenv/versions/3.7.4/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/bkboulton/.pyenv/versions/3.7.4/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I got the same error specifying --python python3.5
.
It sort of looks like maybe we’re trying to evaluate some Python 3.7 code with the Python (3.4 or 3.5) interpreter that we put into the virtual environment.
Expected behavior
If I instead just use the default Python interpreter by not specifying the --python
flag at all or if I specify Python 3.6 or 3.7, it works as expected:
$ python3.7 -m pipx install --python python3.6 cowsay
installed package cowsay 2.0.3, Python 3.6.8
These apps are now globally available
- cowsay
done! ✨ 🌟 ✨
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:13 (8 by maintainers)
Top GitHub Comments
By they way, I really appreciate that you looked into this issue and discussed ways to address it. Pipx is really helpful.
So it appears that mypy won’t work, even using type comments, without the
typing
library.It seems that we either need to add the
typing
library to every venv (creating possible conflicts with the app) or abandon mypy type-checking forvenv_metadata_inspector.py
. https://mypy.readthedocs.io/en/latest/python2.html