question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`pipx install` doesn't seem to work with `--python python3.4`

See original GitHub issue

Describe 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
daytonbcommented, Oct 19, 2019

By they way, I really appreciate that you looked into this issue and discussed ways to address it. Pipx is really helpful.

1reaction
itsayellowcommented, Oct 18, 2019

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 for venv_metadata_inspector.py. https://mypy.readthedocs.io/en/latest/python2.html

To run your program, you must have the typing module in your Python 2 module search path. Use pip install typing to install the module. This also works for Python 3 versions prior to 3.5 that don’t include typing in the standard library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Once system python and pipx upgraded, cannot install new ...
This seems to be specific to using a python3 -m pip (or pip3 ) to install pipx, which causes pipx's shebang to be...
Read more >
Why doesn't pip (or pipX) work for Python3.4
I tried this and received a zipimport error. I'm not sure why, but it looks like my build of Python was atypical. I...
Read more >
Troubleshooting - pipx
This is a good fix for the following problems: System python was upgraded and the python used with a pipx-installed package is no...
Read more >
Help. I have reached an issue that is preventing me from ...
Because my python command doesn't seem to work as normal. ... First, when I run the command python3 -m pip install --user pipx...
Read more >
Python Like A Pro: Managing Global Packages
Glances will not appear on this list. To see a list of tools installed by pipx , use the pipx list command. You...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found