Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rehashing is not applied after pip install in venv #2914

Closed
hylowaker opened this issue Feb 28, 2024 · 1 comment
Closed

Rehashing is not applied after pip install in venv #2914

hylowaker opened this issue Feb 28, 2024 · 1 comment
Labels
by-design the reported behavior is as intended

Comments

@hylowaker
Copy link

Description

  • Platform information: macOS Sonoma 14.2.1
  • OS architecture: amd64
  • pyenv version: 2.3.36
  • Python version: 3.10.12

Steps to Reproduce

$ python -m venv venv
$ source venv/bin/activate
(venv) $ pip install ansible==5.7.1
...
(venv) $ command -v ansible
/Users/jaeheunghan/Desktop/MM2/venv/bin/ansible
(venv) $ ansible --version
ansible [core 2.14.6]    ⬅️⬅️ No, this is not what I installed.
...
(venv) $ command -v ansible
/Users/jaeheunghan/.pyenv/shims/ansible    ⬅️⬅️ What??
(venv) $ pyenv rehash
(venv) $ ansible --version 
ansible [core 2.12.10]    ⬅️⬅️ Correct one.
...
(venv) $ command -v ansible
/Users/jaeheunghan/Desktop/MM2/venv/bin/ansible

Full terminal output

terminal.txt

Note

No problem occurs if I remove eval "$(pyenv init -)" line from my .zshrc file and manually executes Python by ~/.pyenv/shims/python.

@native-api
Copy link
Member

native-api commented Jun 9, 2024

Pyenv cannot intercept command invocations if you activate a virtualenv with source <...>/activate (that's because it prepends its location to PATH, overriding shims).
You need to rather create an env with Pyenv-Virtualenv and either activate with it with it as well or select like a regular Pyenv-managed version (see https://github.com/pyenv/pyenv-virtualenv?tab=readme-ov-file#usage).

@native-api native-api added the by-design the reported behavior is as intended label Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
by-design the reported behavior is as intended
Projects
None yet
Development

No branches or pull requests

2 participants