Closed anentropic closed 11 months ago
maybe I'm supposed to install it to the non-pyenv system python3 though?
there are problems with completions as I have it currently
$ source ~/.bashrc
pyenv: register-python-argcomplete: command not found
The `register-python-argcomplete' command exists in these Python versions:
3.7.4
I was running into the exact same problem, at least with the command not found issue.
I'd have the command not found after starting the shell but i'd be able to run the eval afterwards and it would work, my problem was that I had the eval "$(register-python-argcomplete pipx)" before I sourced the pyenv completion.
Seeing as how yours still doesn't find the command afterwards I'd look into seeing if you have pyenv completions set up in your ~/.bashrc at all.
I come here to ask how to get pipx
working when you already have pyenv
installed... and I find I already asked 6 months ago, with no resolution.
I really want to follow the installation instructions https://pipxproject.github.io/pipx/installation/ rather than have a weird hacked together set up...
But they don't work if you already have pyenv
installed.
Firstly:
$ python3 -m pip install --user pipx
pyenv: python3: command not found
$ brew install python
Warning: python 3.7.6_1 is already installed, it's just not linked
You can use `brew link python` to link this version.
$ brew link python
Linking /usr/local/Cellar/python/3.7.6_1...
Error: Could not symlink Frameworks/Python.framework/Headers
Target /usr/local/Frameworks/Python.framework/Headers
is a symlink belonging to python@2. You can unlink it:
brew unlink python@2
To force the link and overwrite all conflicting files:
brew link --overwrite python
To list all files that would be deleted:
brew link --overwrite --dry-run python
$ brew link --overwrite python
Linking /usr/local/Cellar/python/3.7.6_1... 28 symlinks created
$ python3
Python 3.7.6 (default, Dec 30 2019, 19:38:28)
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
ok I guess we're ready to try again...
python3 -m pip install --user pipx
Collecting pipx
Downloading https://files.pythonhosted.org/packages/c3/63/b461c6996147fe72f7af6a1e108c817a8fa41d9bd744863b4993c8788553/pipx-0.15.1.3-py3-none-any.whl
Requirement already satisfied: argcomplete<2.0,>=1.9.4 in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (from pipx) (1.10.0)
Requirement already satisfied: userpath in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (from pipx) (1.2.0)
Requirement already satisfied: click in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (from userpath->pipx) (7.0)
Requirement already satisfied: distro in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (from userpath->pipx) (1.4.0)
Installing collected packages: pipx
WARNING: The script pipx is installed in '/Users/anentropic/Library/Python/3.7/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pipx-0.15.1.3
$ python3 -m pipx ensurepath
The directory `/Users/anentropic/.local/bin` is already in PATH. If you are sure you want to proceed, try again with the '--force' flag.
Otherwise pipx is ready to go! ✨ 🌟 ✨
Cool, let's try the next step:
$ pipx completions
pyenv: pipx: command not found
The `pipx' command exists in these Python versions:
3.7.4
$ which pipx
/Users/anentropic/.pyenv/shims/pipx
Ugh.
Let's get rid of this pipx I installed under a pyenv version previously...
$ pyenv shell 3.7.4
$ pip uninstall pipx
Uninstalling pipx-0.14.0.0:
Would remove:
/Users/anentropic/.pyenv/versions/3.7.4/bin/pipx
/Users/anentropic/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipx-0.14.0.0.dist-info/*
/Users/anentropic/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pipx/*
Proceed (y/n)? y
Successfully uninstalled pipx-0.14.0.0
$ pyenv version
3.7.4 (set by /Users/anentropic/.pyenv/version)
$ rm /Users/anentropic/.pyenv/version
$ pyenv version
system (set by /Users/anentropic/.pyenv/version)
$ python3
Python 3.7.6 (default, Dec 30 2019, 19:38:28)
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
$ pipx
-bash: /Users/anentropic/.pyenv/shims/pipx: No such file or directory
Ok we're clean, let's install it again under system Python 3.7.6?
$ python3 -m pip install --user pipx
Requirement already satisfied: pipx in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (0.15.1.3)
Requirement already satisfied: argcomplete<2.0,>=1.9.4 in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (from pipx) (1.10.0)
Requirement already satisfied: userpath in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (from pipx) (1.2.0)
Requirement already satisfied: click in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (from userpath->pipx) (7.0)
Requirement already satisfied: distro in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (from userpath->pipx) (1.4.0)
$ python3 -m pipx ensurepath
The directory `/Users/anentropic/.local/bin` is already in PATH. If you are sure you want to proceed, try again with the '--force' flag.
Otherwise pipx is ready to go! ✨ 🌟 ✨
$ source ~/.bashrc
$ pipx
-bash: pipx: command not found
FFS
after reading https://github.com/standardebooks/tools/issues/188 I can report that installing without --user
flag as suggested there works (after all of the above):
$ python3 -m pip uninstall pipx
Uninstalling pipx-0.15.1.3:
Would remove:
/Users/anentropic/Library/Python/3.7/bin/pipx
/Users/anentropic/Library/Python/3.7/lib/python/site-packages/pipx-0.15.1.3.dist-info/*
/Users/anentropic/Library/Python/3.7/lib/python/site-packages/pipx/*
Proceed (y/n)? y
Successfully uninstalled pipx-0.15.1.3
$ python3 -m pip install pipx
Collecting pipx
Using cached https://files.pythonhosted.org/packages/c3/63/b461c6996147fe72f7af6a1e108c817a8fa41d9bd744863b4993c8788553/pipx-0.15.1.3-py3-none-any.whl
Requirement already satisfied: argcomplete<2.0,>=1.9.4 in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (from pipx) (1.10.0)
Requirement already satisfied: userpath in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (from pipx) (1.2.0)
Requirement already satisfied: distro in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (from userpath->pipx) (1.4.0)
Requirement already satisfied: click in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (from userpath->pipx) (7.0)
Installing collected packages: pipx
Successfully installed pipx-0.15.1.3
$ pipx --version
0.15.1.3
🎉 🎉 🎉
the bash completions need an extra step to work (due to a dependency was previously installed with --user
)...
$ source ~/.bashrc
pyenv: register-python-argcomplete: command not found
The `register-python-argcomplete' command exists in these Python versions:
3.7.4
to fix this we do the same uninstall and reinstall as above:
$ python3 -m pip uninstall argcomplete
Successfully uninstalled argcomplete-1.10.0
$ python3 -m pip install argcomplete
$ pipx
--help -h ensurepath install reinstall-all runpip uninstall-all upgrade-all
--version completions inject list run uninstall upgrade
🎉 🎉 🎉
The current instructions for macOS (which I assume you're using because you're using Homebrew are (from the README.md at https://github.com/pipxproject/pipx):
On macOS:
brew install pipx
pipx ensurepath
I think the key here is that https://pipxproject.github.io/pipx/installation/ does not have the OS-specific installation instructions that README.md does. We need to fix that.
Another thing to note is that when you install using pip install --user pipx
the pipx binary is put in a specific directory that depends on which python you are using. This may or may not already be in your PATH if you're using a non-standard python (like one of the pyenv versions.) The pipx ensurepath
step only puts the binary directory for your pipx packages in your path. I suppose we could look at ensuring that pipx is in your path also at this step.
I suppose we could look at ensuring that pipx is in your path also at this step.
We ran into this before and updated the instructions, which currently have this
Assuming you have pip installed for python3, run:
python3 -m pip install --user pipx
python3 -m pipx ensurepath
That works for the purpose of running pipx ensurepath
, but as far as I understand it, that subcommand doesn't actually check if pipx itself is in the user's path.
The way I install pipx
while using pyenv:
desired outcome is to have
pipx
available globally for the user without poisoningpyenv
python versions - keep them pristine: installpipx
into separate environment akapipx install pipx
install pyenv-virtualenv pyenv
plugin (i.e. clone it into ${PYENV_ROOT}/plugins
)
create separate virtualenv just for pipx
(so regular pyenv's python version stays pristine):
pyenv virtualenv 3.7.7 pipx
specifying python version to be used for pipx
env.
install pipx inside new virtualenv
pyenv activate pipx
pip install pipx
pyenv deactivate
Now,
pipx
is available in${PYENV_ROOT}/shims
. If you are usingpyenv
- this directory should already be in yourPATH
(added byeval "$(pyenv init - )"
).
in order to always run pipx
from within its virtualenv, not from active pyenv
python, add PYENV_VERSION=pipx
to pipx
command (pyenv virtualenv name used in venv creation step) which we preserve in .bashrc
:
alias pipx='PYENV_VERSION=pipx pipx'
# pipx completion, place after pyenv init
if command -v pipx 1>/dev/null 2>&1; then
eval "$(PYENV_VERSION=pipx register-python-argcomplete pipx)"
fi
after reading standardebooks/tools#188 I can report that installing without
--user
flag as suggested there works (after all of the above):$ python3 -m pip uninstall pipx Uninstalling pipx-0.15.1.3: Would remove: /Users/anentropic/Library/Python/3.7/bin/pipx /Users/anentropic/Library/Python/3.7/lib/python/site-packages/pipx-0.15.1.3.dist-info/* /Users/anentropic/Library/Python/3.7/lib/python/site-packages/pipx/* Proceed (y/n)? y Successfully uninstalled pipx-0.15.1.3 $ python3 -m pip install pipx Collecting pipx Using cached https://files.pythonhosted.org/packages/c3/63/b461c6996147fe72f7af6a1e108c817a8fa41d9bd744863b4993c8788553/pipx-0.15.1.3-py3-none-any.whl Requirement already satisfied: argcomplete<2.0,>=1.9.4 in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (from pipx) (1.10.0) Requirement already satisfied: userpath in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (from pipx) (1.2.0) Requirement already satisfied: distro in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (from userpath->pipx) (1.4.0) Requirement already satisfied: click in /Users/anentropic/Library/Python/3.7/lib/python/site-packages (from userpath->pipx) (7.0) Installing collected packages: pipx Successfully installed pipx-0.15.1.3 $ pipx --version 0.15.1.3
🎉 🎉 🎉
this worked for me, thanks!
The way I install
pipx
while using pyenv:desired outcome is to have
pipx
available globally for the user without poisoningpyenv
python versions - keep them pristine: installpipx
into separate environment akapipx install pipx
- install pyenv-virtualenv
pyenv
plugin (i.e. clone it into${PYENV_ROOT}/plugins
)- create separate virtualenv just for
pipx
(so regular pyenv's python version stays pristine):pyenv virtualenv 3.7.7 pipx
specifying python version to be used forpipx
env.install pipx inside new virtualenv
pyenv activate pipx pip install pipx pyenv deactivate
Now,
pipx
is available in${PYENV_ROOT}/shims
. If you are usingpyenv
- this directory should already be in yourPATH
(added byeval "$(pyenv init - )"
).in order to always run
pipx
from within its virtualenv, not from activepyenv
python, addPYENV_VERSION=pipx
topipx
command (pyenv virtualenv name used in venv creation step) which we preserve in.bashrc
:alias pipx='PYENV_VERSION=pipx pipx' # pipx completion, place after pyenv init if command -v pipx 1>/dev/null 2>&1; then eval "$(PYENV_VERSION=pipx register-python-argcomplete pipx)" fi
This worked for me after I tried anentropic's suggestion of uninstalling pipx
and then reinstalling it without the --user
flag. I am using WSL2, Ubuntu 22.04 Bash shell on a Windows 10.
I was having the issue where even though reinstalling pipx
without the --user
flag (via python3 -m pip install pipx
) would install the pipx
binary to /home/bethany/.pyenv
directory, it would assume that it didn't need to install its dependencies because they were still available inside the /home/bethany/.local
directory. So, I tried manually removing the /home/bethany/.local
directory using sudo rm -rf /home/bethany/.local
. (Note: I ensured that I only had the recently installed pipx
dependencies inside this folder before removing it!)
This still was ineffective because even though the python3 -m pip install pipx
command would install pipx
and its dependencies inside the /home/bethany/.pyenv directory
, when I ran pipx
inside my shell it would complain that there was no pipx
command found inside of the /home/bethany/.local directory
.
However, after following the above instructions everything works just fine! After running:
$ pyenv virtual env pipx 3.13.0
$ pyenv activate pipx
$ pip3 install pipx
Installing collective packages: platformdirs, packaging, argcomplete, click, userpath, pipx
Successfully installed argcomplete-3.5.1, click-8.1.7, packaging-24.1, pipx-1.7.1, platformdirs-4.3.6, userpath-1.9.2
$ pyenv deactivate
$ echo "alias pipx=`PYENV_VERSION=pipx pipx`" >> ~/.bashrc
$ pipx --version
pipx-1.7.1
$ which pipx
pipx is aliased to `PYENV_VERSION=pipx pipx`
pipx is /home/bethany/.pyenv/shims/pipx
Everything is working great! I actually didn't even have to manually install pyenv-virtualenv
, I guess with the most recent pyenv
I had installed (pyenv-2.4.16
) the pyenv-virtualenv
plugin is installed automatically along with pyenv
.
I guess this is some kind of unanticipated interaction with pyenv
This fixed it:
it was the
pyenv shell
specifically which seemed to be out of sync, before setting that it had installedpipx
to one of my other python 3s which was not currently on the PATH