Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Angus Hollands
    @agoose77:matrix.org
    [m]
    is there a bash_profile or bashrc in your $HOME too?
    coxoperationsengineer
    @coxoperationsengineer
    there is but it is empty
    Angus Hollands
    @agoose77:matrix.org
    [m]
    which one do you have?
    coxoperationsengineer
    @coxoperationsengineer
    .bash_profile
    Angus Hollands
    @agoose77:matrix.org
    [m]
    OK. Is that where you would normally set your $PATH variables?
    Also, is ZSH your login shell?
    coxoperationsengineer
    @coxoperationsengineer
    No normally I set them in .zshrc, and yes ZSH is the default login shell now in Mac OS Big Sur on a clean install
    coxoperationsengineer
    @coxoperationsengineer
    @agoose77:matrix.org it also appears that by default there is not a ~/.zprofile in Mac OS, but there is a zprofile in /etc with the following
    # System-wide profile for interactive zsh(1) login shells.
    
    # Setup user specific overrides for this in ~/.zprofile. See zshbuiltins(1)
    # and zshoptions(1) for more details.
    
    if [ -x /usr/libexec/path_helper ]; then
        eval `/usr/libexec/path_helper -s`
    fi
    agoose77
    @agoose77:matrix.org
    [m]
    OK. Let's assume that macosx respects ~/.zprofile, then you just need to modify that file
    However, where are you currently adding pyenv to path?
    coxoperationsengineer
    @coxoperationsengineer

    Generally speaking you can put any settings in ~/.zshrc. It is loaded regardless if the shell is interactive, login, or not. ~/.zprofile does not load for non-login shells, but in macOS the default behavior in the terminal is to launch new shells as a login shell

    So I have my pyenv init statement in ~/.zshrc and have had it there working for almost 2 years, until I got the warning message after brew updated pyenv to 2.0

    Angus Hollands
    @agoose77:matrix.org
    [m]
    @coxoperationsengineer: yes, I read that whilst checking the sourcing order on MacOS 🙂 It's not a question of "can I?", but more "should I?; not all shells should be login shells and although terminals still load bashrc, they are an exception
    So the proper answer is - move your PATH configuration for pyenv to .zprofile, and add a new line for eval "$(pyenv init --path)"
    If you really don't want to do that, then the short answer is that you now need to add the shims to your PATH, which is what eval "$(pyenv init --path)" does.
    You also need to set PYENV_ROOT if I recall correctly, e.g. this answer https://github.com/pyenv/pyenv/issues/1906#issuecomment-834751771
    coxoperationsengineer
    @coxoperationsengineer
    so $(pyenv virtualenv-init -) does it stay put, and just move pyenv to .zprofile?
    Angus Hollands
    @agoose77:matrix.org
    [m]
    That stays put for now - they haven't split the configuration into bash-shell vs path configuration parts yhet
    coxoperationsengineer
    @coxoperationsengineer
    I guess the bigger question, does the warning go away when this is configured properly?
    Angus Hollands
    @agoose77:matrix.org
    [m]
    Yes
    coxoperationsengineer
    @coxoperationsengineer

    OK so far no go, the instructions state: MacOS note: If you installed Pyenv with Homebrew, you don't need to add the PYENV_ROOT= and PATH= lines. You also don't need to add commands into ~/.profile if your shell doesn't use it.

    so I created ~/.zprofile and simply put eval "$(pyenv init --path)" inside of it.

    I left the following in .zshrc per the instructions:
    eval "$(pyenv init -)"
    eval "$(pyenv virtualenv-init -)"

    restart the terminal, message is still there.

    Angus Hollands
    @agoose77:matrix.org
    [m]
    Any changes to z profile don't take effect until you log out and in again
    coxoperationsengineer
    @coxoperationsengineer
    @agoose77:matrix.org ok I will try it again, the instructions state for Mac OS that changes don't require a log out, so didn't attempt it, just restarted terminal
    Jeremy Cantrell
    @jmcantrell

    I'm confused about how modules are being located. I've installed pyenv as a git clone and am able to install python versions, but they seem there seems to be a discrepancy regarding sys.path.

    I've installed a version and selected it: pyenv global 3.9.5

    When installing a package with: pip install msgpack

    I get the output:

    Defaulting to user installation because normal site-packages is not writeable
    Requirement already satisfied: msgpack in /usr/lib/python3.9/site-packages (1.0.2)

    But when I try to use that package at a python repl:

    Python 3.9.5 (default, May  8 2021, 22:00:35)
    [GCC 10.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import msgpack
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ModuleNotFoundError: No module named 'msgpack'

    And sys.path does not show /usr/lib/python3.9/site-packages:

    >>> import sys; print(sys.path)
    ['', '/home/jeremy/.pyenv/versions/3.9.5/lib/python39.zip', '/home/jeremy/.p5/lib/python3.9', '/home/jeremy/.pyenv/versions/3.9.5/lib/python3.9/lib-dynly/.local/lib/python3.9/site-packages', '/home/jeremy/.pyenv/versions/3.9.5/lpackages']
    It looks like I can do pip install --force-reinstall as a workaround, but why does the install command above see /usr/lib but not python?
    Angus Hollands
    @agoose77:matrix.org
    [m]
    @jmcantrell: what happens when you run which pip and pyenv which pip?
    Jeremy Cantrell
    @jmcantrell
    @agoose77:matrix.org ~/.pyenv/shims/pip and ~/.local/bin/pip, respectively.
    and the shebang line for ~/.local/bin/pip is #!/usr/bin/python.
    Angus Hollands
    @agoose77:matrix.org
    [m]
    What does ls $PYENV_ROOT/versions yield?
    Jeremy Cantrell
    @jmcantrell
    a bunch of version directories, one of which is 3.9.5
    Angus Hollands
    @agoose77:matrix.org
    [m]
    OK. Just for my own sanity, with your env activated, does python -m pip install msgpack give the same results? It looks like pip is finding the system installed packge, which it shouldn't when inside a venv.
    Jeremy Cantrell
    @jmcantrell
    are pyenv versions venvs?
    Kal Sze
    @ksze

    are pyenv versions venvs?

    no

    Jeremy Cantrell
    @jmcantrell
    I get "No module named pip" for python -m pip install
    Kal Sze
    @ksze
    pyenv versions are like base installations of Python. You should then use venv, virtualenvwrapper, pipenv, poetry, or the like to create your virtual environment.
    Have you properly initialized pyenv?
    Jeremy Cantrell
    @jmcantrell
    As far as I know. I followed the instructions, pyenv doctor gives the thumbs up, and I've been able to install and use versions.
    Weird. I don't get the not found error on a different version. Gonna reinstall 3.9.5.
    Kal Sze
    @ksze
    I think it's odd that pyenv which pip points you to ~/.local/bin/pip, which then contains #!/usr/bin/python
    Jeremy Cantrell
    @jmcantrell
    Definitely weird
    Kal Sze
    @ksze
    (because you're supposed to be using 3.9.5 from pyenv now)
    Angus Hollands
    @agoose77:matrix.org
    [m]
    Yes, that's what I'm confused about. I just re-installed pyenv to see whether it's a wierd artefact
    Jeremy Cantrell
    @jmcantrell
    And probably my fault. I'm just trying to figure out what I did wrong.
    Kal Sze
    @ksze
    pyenv which pip should have pointed you to $HOME/.pyenv/versions/3.9.5/bin/pip.
    Angus Hollands
    @agoose77:matrix.org
    [m]
    I wonder whether that is what happens when the installed Python doesn't have pip, i.e. the shim falls through to the system
    @jmcantrell: does $PYENV_ROOT/versions/3.9.5/bin/pip exist?
    Kal Sze
    @ksze
    @agoose77:matrix.org but 3.9.5 should come with pip already, no?
    Jeremy Cantrell
    @jmcantrell
    Shoot. I already uninstalled it to reinstall.
    Angus Hollands
    @agoose77:matrix.org
    [m]
    @ksze: absolutely, but sometimes pip can be missing in Python installations. It shouldn't be in pyenv though
    Jeremy Cantrell
    @jmcantrell
    ok, after reinstall, pyenv which pip reports the correct path.
    Is it best to avoid --user installs with pyenv's pip?