[Python] Linking pyenv python to homebrew in order to avoid homebrew python@3.8 installation

Discussão em 'Python' iniciado por Stack, Dezembro 19, 2024.

  1. Stack

    Stack Membro Participativo

    Some packages from brew require python@3.8 as a dependency. For example:

    $ brew deps vim
    gdbm
    gettext
    libyaml
    lua
    openssl@1.1
    perl
    python@3.8
    readline
    ruby
    sqlite
    xz


    However, I want to manage all my python installations with pyenv and I would not like to download python@3.8 with brew. This would imply having to exactly same versions of python installed in 2 different locations, which I would like to avoid. Reading up on brew, pyenv and python I´ve come to understand that having python installed in different parts of the system may cause some trouble in the future, which I'd also like to avoid. Unfortunately I cannot seem to resolve the python dependency in brew packages through pyenv. Below follow the steps I've tried to overcome this.

    I have installed pyenv with brew, and necessary python versions from there.

    $ pyenv versions
    system
    * 3.8.2 (set by PYENV_VERSION environment variable)


    I have tried solving this according to this Github discussion by setting a brew alias such as:

    alias brew='env PATH=${PATH//$(pyenv root)\/shims:/} brew'


    As that did not resolve the dependency issue, I tried create a link for python@3.8 in /usr/local/Cellar which would point to the pyenv python, somehow similar to this issue with:

    ln -s ~/.pyenv/versions/3.8.2 $(brew --cellar python)@3.8


    This did not work, so I have also tried adding the link to ´/usr/local/bin´:

    ln -s ~/.pyenv/versions/3.8.2 /usr/local/bin/python@3.8


    However, running brew info vim still shows that the python@3.8 dependency is not satisfied.

    $ brew info vim
    vim: stable 8.2.0900 (bottled), HEAD
    Vi 'workalike' with many additional features
    https://www.vim.org/
    Conflicts with:
    ex-vi (because vim and ex-vi both install bin/ex and bin/view)
    macvim (because vim and macvim both install vi* binaries)
    Not installed
    From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/vim.rb
    ==> Dependencies
    Required: gettext ✘, lua ✘, perl ✘, python@3.8 ✘, ruby ✘


    Any ideas how can I link/connect my pyenv python installation to homebrew so that the additional python@3.8 is not installed? Or maybe solve the issue in another manner using pyenv global/local/shell? I am currently using macOs Catalina.

    Any help is greatly appreciated!

    Continue reading...

Compartilhe esta Página