0

The issue:

So, as per recommendation I have uninstalled local python versions (except for the Mac default one) and installed pyenv-virtualvenv through brew. (see: [installed python packages in wrong folder][1])

However, 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.

Summary:

Since the packages are installed to a wrong path, I cannot use them, as it will state the module is not found.

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$:

myusername@MacBook ~ % echo $PATH
/Users/myusername/.pyenv/shims:/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

While 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
  1. Do I maybe need to change export PATH="$PYENV_ROOT/bin:$PATH" this, so the none-existent path /Users/myusername/.pyenv/bin, will be corrected as: /Users/myusername/.pyenv/versions/3.11.1/bin? How would it look like correctly then? export PATH="$PYENV_ROOT/versions/3.11.1/bin:$PATH"? Answer: I tried this, but it didn't change anything. Packages are still loaded to homebrew library.

I am really at a loss, at what's causing the issue, as the used python versions seem to be ok and belonging to pyenv.

  1. Would it be also an option to uninstall brew and try again? or would that break my current pyenv setup?

Might my bash profile help to figure things out?

% nano .bash_profile

@MacBook~ % source .bash_profile
‘FROM BASH_PROFILE’
HOME=/Users/myusername
HOMEBREW_CELLAR=/opt/homebrew/Cellar
HOMEBREW_PREFIX=/opt/homebrew
HOMEBREW_REPOSITORY=/opt/homebrew
INFOPATH=/opt/homebrew/share/info:
LC_CTYPE=UTF-8
LOGNAME=myusername
MANPATH=/opt/homebrew/share/man::
OLDPWD=/Users/myusername
PATH=/Users/myusername/.pyenv/shims:/Users/myusername/.pyenv/versions/3.11.1/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
PWD=/Users/myusername
PYENV_ROOT=/Users/myusername/.pyenv
PYENV_SHELL=zsh
SHELL=/bin/zsh
(some things. I am going to skip:)
pyenv:12: command not found: pyenv

Thank you! [1]: Installed python packages will stay in site packages 3.10?

jms
  • 215
  • 1
  • 7
  • You say you tried all of `pip`, `pip3`, `python` and `python3`. What output do you get when you run `which` for those commands? E.g. `which pip3` – Grismar Feb 11 '23 at 03:53
  • @Grismar thank you for the reply! As stated above 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` – jms Feb 11 '23 at 05:44

0 Answers0