简体   繁体   中英

How to remove a package installed via pyenv/pip

I have a confusing situation with executables on path that were installed via pyenv/pip. The story starts with me having multiple python interpreters with a given package. Today I have learned about pipx , which is supposed to provide me with a system-independent executable made of python package (executable). After installing the package, pipx correctly warns me that it already exists. However, it is less clear how to get rid of it on my path to be able to use the new, correct executable.

I have tried literally removing the file on the path that was found as duplicate, which led to a funny situation below:

my_machine:proj_a ikkamens$ pipx install flynt --python python3.8
⚠️  Note: flynt was already on your PATH at /Users/ikkamens/.pyenv/shims/flynt
  installed package flynt 0.40.1, Python 3.8.0
  These apps are now globally available
    - flynt
done! ✨ 🌟 ✨
my_machine:proj_a ikkamens$ flynt --help
pyenv: flynt: command not found

The 'flynt' command exists in these Python versions:
  3.6.8/envs/blues
  3.7.3
  3.8-dev
  blues

my_machine:proj_a ikkamens$ rm /Users/ikkamens/.pyenv/shims/flynt
my_machine:proj_a ikkamens$ flynt
-bash: /Users/ikkamens/.pyenv/shims/flynt: No such file or directory
my_machine:proj_a ikkamens$ cd
my_machine:~ ikkamens$ cat .bashrc | grep fl
my_machine:~ ikkamens$ which flynt
/Users/ikkamens/.local/bin/flynt
my_machine:~ ikkamens$ flynt
-bash: /Users/ikkamens/.pyenv/shims/flynt: No such file or directory

How is it possible that which returns not the same as what is executed? Note that my .bashrc doesn't contain any alias or similar (grep statement). how to completely get rid of whatever is left of old installation?

As commented by @jordanm, the problem due to bash hashing PATH lookup.

my_machine:~ ikkamens$ rm /Users/ikkamens/.pyenv/shims/flynt
my_machine:~ ikkamens$ flynt
-bash: /Users/ikkamens/.pyenv/shims/flynt: No such file or directory
my_machine:~ ikkamens$ which flynt
/Users/ikkamens/.local/bin/flynt
my_machine:~ ikkamens$ hash -r
my_machine:~ ikkamens$ flynt
Running flynt v.0.40.1

With pyenv you have different isolated python environments. First of all you have to activate one of pyenv environments:

# check which virtual environments you have
pyenv virtualenvs

# activate one
pyenv activate blues
# seems that `blues` is your virtual environment with python 3.6.8
# then install your package into active virtual environment
pip install flynt
# also uninstall packages while being in your environment

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM