skip to Main Content

For somehow I fully messed up with my python3.

I’m working on a Mac with Ventura 13.2.1, here is some key APPs path:

type: xcode-select -p -> print: "/Applications/Xcode.app/Contents/Developer"
type: which python -> print: "python not found" -> Looks fine to me since I should only need Python3
type: which python3 -> print: "/usr/bin/python3"
type: which pip3 -> print:"/usr/bin/pip3"

Trying to install numpy with pip3 -> type: pip3 install numpy -> print:

Traceback (most recent call last):
  File "/Applications/Xcode.app/Contents/Developer/usr/bin/pip3", line 5, in <module>
    from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip'

Kind of wired since I think I already have lots of python3 packages installed under this path:
"/Users/<user_name>/Library/Python/3.9/lib/python/site-packages" -> Because from there I can print stuffs from "numpy", "pandas" and many others -> But if I type: which numpy / numpy –version / which pandas / pandas –version -> It will all print "command not found" related stuff.

Thus I wondering both my python3 and pip3 are installed in all different paths, which is occurs in:

/Applications/Xcode.app/Contents/Developer/usr/bin
or 
/usr/bin
or 
/Users/<user_name>/Library

In this case how I can fully clean my python3 and pip3 and let it be pointed correctly in the Mac system under xcode, or this is something else?

Thanks

All in the descriptions

2

Answers


  1. Chosen as BEST ANSWER

    Thanks Samuel for the response. Installed and config pyenv indeed solved part of this issue, after install & config pyenv -> I choose ->$ pyenv global 3.9.7 as my python version, here is some output:

    ->$ which python3  ->   "/Users/<user_name>/.pyenv/shims/python3"
    ->$ which pip3 ->  "/Users/<user_name>/.pyenv/shims/pip3"
    ->$ python3 --version   ->   "Python 3.9.7"
    ->$ pip3 --version   ->  "pip 21.2.3 from 
    

    /Users/<user_name>n/.pyenv/versions/3.9.7/lib/python3.9/site-packages/pip (python 3.9)"

    it looks fixed both of python3 and pip3 path to be in the same place under .pyenv, however trying to install numpy or pandas again:

    @kidatemoris-Mac-mini ~ % pandas -v
    zsh: permission denied: pandas
    @kidatemoris-Mac-mini ~ % sudo pandas -v
    Password:
    sudo: pandas: command not found
    

    Looks like still not be able to found its installed packages


  2. To use python, you may add a soft link to python3 with link -s /usr/bin/python3 /usr/bin/python.

    The best way is to use pyenv to manage your python environment.
    https://github.com/pyenv/pyenv . It has the instruction to make the installation simple.

    You can create many python environments such as py37, anaconda, py39, project, test and etc.

    Just use pyenv activate py39 to activate python 3.9 environment which you created.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search