$PATH broken for python environments?

Whenever I try to install something through pip/pip3/python/python3 it will install the package in the folder /opt/homebrew/lib/python3.10/site-packages although there is no python 3.10 installed in /opt/homebrew (or cellar) anymore. I also ran brew doctor and brew cleanup --prune=all, both seemingly fine.


My Setup:

Specs:

Macbook Air M1 Ventura
Visual Studio Code Version: 1.75.0

check for versions:

myusername@MacBook ~ % which pip
/Users/myusername/.pyenv/shims/pip

myusername@MacBook ~ % which pip3
/Users/myusername/.pyenv/shims/pip3

myusername@MacBook ~ % which python
/Users/myusername/.pyenv/shims/python

myusername@MacBook ~ % which python3
/Users/myusername/.pyenv/shims/python3

myusername@MacBook ~ % pyenv versions
  system
* 3.11.1 (set by /Users/myusername/.pyenv/version)
  3.11.1/envs/venv_mypyenv_playground
  venv_mypyenv_playground

myusername@MacBook ~ % which brew
/opt/homebrew/bin/brew

check for PATH:

/Users/<myusername>/.pyenv/shims:/Users/<myusername>/.pyenv/bin:/Users/<myusername>/.pyenv/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/usr/local/go/bin:/Library/Apple/usr/bin


Side note: For some reason `Users/<myusername>/.pyenv/bin` is in there twice (I am not sure why, because it used to be there once and I didn't change the setup afaik)


hile there's the path /Users/myusername/.pyenv/shims, there is no path: /Users/myusername/.pyenv/bin, but: /Users/myusername/.pyenv/versions/3.11.1/bin

  1. Maybe that is part of the problem? If so, how can I amend the PATH$ correctly?

Check on Bash and ZSH Setup:

I was wondering if there's something wrong with some bash or zshcr files, which causes python to prioritize homebrew. This is how they look:

My setup:

.bash_profile
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

.bashrc is empty

.zprofile
# set PATH, MANPATH, etc., for Homebrew.
eval "$(/opt/homebrew/bin/brew shellenv)"

.zshrc
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
fi


How can I make sure the path where python will install packages is NOT homebrew/lib/Python3.10 anymore? (Since it doesn't have a corresponding python version, it won't work)

How can I delete the duplicate `Users/<myusername>/.pyenv/bin` in $PATH?

MacBook Air 13″, macOS 13.2

Posted on Feb 12, 2023 11:02 PM

Reply
1 reply

Feb 14, 2023 11:04 AM in response to 5jms2

You lost me the minute I saw "homebrew". These developer forums have been practically taken over by people trying to do simple things in homebrew only to find out that they can't even run "ls" anymore.


Your setup is problematic. bash and zsh are two different environments. If you are mixing them up, then you're bound to have problems. .zprofile is particularly interesting. That is just "let homebrew take over my life". You would have to ask the homebrew developers what that does. I see no reason to assume it is anything other that "let homebrew take over my life".

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

$PATH broken for python environments?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.