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 exits with code 1 when called from Git Bash for Windows

See original GitHub issue

Describe the bug

Get exit code 1 when I run the pipx command on Git Bash for Windows.

$ which -a pipx
/c/Users/thecesrom/AppData/Roaming/Python/Python310/Scripts/pipx
/c/users/thecesrom/appdata/roaming/python/python310/scripts/pipx
$ pipx
$ echo $?
1
$ cat ~/.local/pipx/logs/cmd_2022-03-04_15.56.56.log
   394.8ms (setup:727): 2022-03-04 15:56:56
   394.8ms (setup:728): C:\Users\thecesrom\AppData\Roaming\Python\Python310\site-packages\pipx\__main__.py
   394.8ms (setup:729): pipx version is 1.0.0
   394.8ms (setup:730): Default python interpreter is 'C:\\Python\\Python310\\python.exe'
   400.8ms (cli:790): pipx finished.

The only way I can get pipx to run is by using python -m pipx.

$ python -m pipx --version
1.0.0
$ python -m pipx ensurepath
C:\Users\thecesrom\.local\bin is already in PATH.
C:\Users\thecesrom\AppData\Roaming\Python\Python310\Scripts is already in PATH.

All pipx binary directories have been added to PATH. If you are sure you want
to proceed, try again with the '--force' flag.

Otherwise pipx is ready to go!

Or by creating an alias (alias pipx="python -m pipx").

$ alias pipx="python -m pipx"
$ pipx --version
1.0.0

I have tried with a clean .bashrc file, but it still fails.

How to reproduce

Pre-requisites

  • Windows
  • Git for Windows
  • Python
  • pipx
  1. Open Git Bash
  2. Run pipx

Expected behavior

pipx should run without errors just like it does on all other shells. pipx does run in PowerShell, and Command Prompt without issues.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
julie777commented, Mar 8, 2022

I was having all the problems with pip 22.0.3. I just checked and pip22.0.4 downgraded distlib to 0.3.3 which undos the distlib change that broke the wrappers generated on Windows.

0reactions
thecesromcommented, Mar 7, 2022

Just as an experiment I uninstalled pipx, and reinstalled from scratch. This meant removing all the pipx directory from ~/.local/pipx, and my issue cleared on its own; now pipx runs as an executable on Git Bash.

Clean install

Click to expand
$ python --version
Python 3.10.2
$ python -m pip freeze | xargs python -m pip uninstall -y
...
$ python -m pip list
Package    Version
---------- -------
pip        22.0.4
setuptools 60.9.3
wheel      0.37.1
$ python -m pip install --user pipx
Collecting pipx
  Using cached pipx-1.0.0-py3-none-any.whl (54 kB)
Collecting packaging>=20.0
  Using cached packaging-21.3-py3-none-any.whl (40 kB)
Collecting userpath>=1.6.0
  Using cached userpath-1.8.0-py3-none-any.whl (9.0 kB)
Collecting argcomplete>=1.9.4
  Using cached argcomplete-2.0.0-py2.py3-none-any.whl (37 kB)
Collecting colorama>=0.4.4
  Using cached colorama-0.4.4-py2.py3-none-any.whl (16 kB)
Collecting pyparsing!=3.0.5,>=2.0.2
  Using cached pyparsing-3.0.7-py3-none-any.whl (98 kB)
Collecting click
  Using cached click-8.0.4-py3-none-any.whl (97 kB)
Installing collected packages: pyparsing, colorama, argcomplete, packaging, click, userpath, pipx
Successfully installed argcomplete-2.0.0 click-8.0.4 colorama-0.4.4 packaging-21.3 pipx-1.0.0 pyparsing-3.0.7 userpath-1.8.0
$ python -m pip list
Package     Version
----------- -------
argcomplete 2.0.0
click       8.0.4
colorama    0.4.4
packaging   21.3
pip         22.0.4
pipx        1.0.0
pyparsing   3.0.7
setuptools  60.9.3
userpath    1.8.0
wheel       0.37.1
$ python -m pipx ensurepath
C:\Users\thecesrom\.local\bin is already in PATH.
C:\Users\thecesrom\AppData\Roaming\Python\Python310\Scripts is already in PATH.

⚠️  All pipx binary directories have been added to PATH. If you are sure you want to proceed, try again with the '--force' flag.  

Otherwise pipx is ready to go! ✨ 🌟 ✨
$ cd ~/.local/pipx/
$ ls -al
total 4
drwxr-xr-x 1 thecesrom 1049089 0 Mar  7 10:45 ./
drwxr-xr-x 1 thecesrom 1049089 0 Mar  7 10:45 ../
drwxr-xr-x 1 thecesrom 1049089 0 Mar  7 10:45 .cache/
drwxr-xr-x 1 thecesrom 1049089 0 Mar  7 10:45 logs/
drwxr-xr-x 1 thecesrom 1049089 0 Mar  7 10:45 venvs/
$ ls -al venvs
total 0
drwxr-xr-x 1 thecesrom 1049089 0 Mar  7 10:45 ./
drwxr-xr-x 1 thecesrom 1049089 0 Mar  7 10:45 ../

pipx-installed packages

Click to expand

So only pipx is installed globally, and these are the packages I install using pipx:

Packages:

  • black
  • flake8
  • isort
  • pre-commit
  • pydocstyle[toml]
  • pylint
  • pyproject-fmt
  • setup-cfg-fmt
  • sort-all
$ ls -al ~/.local/pipx/venvs
total 20
drwxr-xr-x 1 thecesrom 1049089 0 Mar  7 10:58 ./
drwxr-xr-x 1 thecesrom  1049089 0 Mar  7 10:57 ../
drwxr-xr-x 1 thecesrom 1049089 0 Mar  7 10:57 black/
drwxr-xr-x 1 thecesrom 1049089 0 Mar  7 10:57 flake8/
drwxr-xr-x 1 thecesrom  1049089 0 Mar  7 10:57 isort/
drwxr-xr-x 1 thecesrom 1049089 0 Mar  7 10:57 pre-commit/
drwxr-xr-x 1 thecesrom 1049089 0 Mar  7 10:57 pydocstyle/
drwxr-xr-x 1 thecesrom 1049089 0 Mar  7 10:58 pylint/
drwxr-xr-x 1 thecesrom 1049089 0 Mar  7 10:58 pyproject-fmt/
drwxr-xr-x 1 thecesrom 1049089 0 Mar  7 10:58 setup-cfg-fmt/
drwxr-xr-x 1 thecesrom 1049089 0 Mar  7 10:58 sort-all/

And all packages seem to be working fine. So a clean install fixed it for me using pip 22.0.4,

Conclusion

So the first time I installed pipx was when Python 3.10.2 was released (2022-01-14) which came with pip 21.2.4 according to the Release Notes, and bpo-45343.

And then I reinstalled pipx without cleaning the ~/.local/pipx directory, if it even matters.

So I’m guessing that it is not entirely a pip-related issue, since I am using the latest version (22.0.4), and pipx and all pipx-installed packages seem to be working fine after a clean installation.

Maybe this could shed some light.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pipenv script won't run on Windows using Git Bash
SOLUTION 1: I was calling Poetry to try and make sense of it as well and then I tried calling both applications from...
Read more >
pipenv Documentation - Read the Docs
The command will perform a verification, and return an exit code 1 when dependency locking is needed. This may be useful for cases...
Read more >
Add executable to Ubuntu-latest PATH using GitHub workflow
/home/runner/work/_temp/long-alpha-numeric-string.sh: line 1: myapp: command not found Error: Process completed with exit code 127. This error ...
Read more >
Git hook failure "Executable poetry not found" when commiting ...
I have poetry installed using pipx and the executable is located in ~/.local/bin/ . This directory is added to my path in my...
Read more >
Error: Command '['/path/to/env/bin/python3.7', '-Im', 'ensurepip ...
7', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1. python3 -m venv env0 worked fine before. Why does this ...
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