[Python] Python cannot find package after pip install

Discussão em 'Python' iniciado por Stack, Novembro 27, 2024.

  1. Stack

    Stack Membro Participativo

    I'm trying to install sumo using pip3 install --user sumo with Python@3.9 However although the sumo package is already installed, it cannot be invoked by which sumo, and same problem for which scipy & which numpy

    In the site-package folder I can find all these packages, so it is definitely properly installed by pip3

    Edited:

    python3 -m site

    sys.path = [
    '/Users/tonyspc',
    '/usr/local/lib/python3.9/site-packages',
    '/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python39.zip',
    '/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9',
    '/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload',
    '/Users/tonyspc/Library/Python/3.9/lib/python/site-packages',
    '/usr/local/Cellar/sip/6.1.1/libexec/lib/python3.9/site-packages',
    '/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages',
    ]
    USER_BASE: '/Users/tonyspc/Library/Python/3.9' (exists)
    USER_SITE: '/Users/tonyspc/Library/Python/3.9/lib/python/site-packages' (exists)
    ENABLE_USER_SITE: True



    My current PATH for Python3 and pip3 is:

    which python3
    /usr/local/opt/python@3.9/bin/python3

    which pip3
    /usr/local/opt/python@3.9/bin/pip3



    I searched a little bit for solutions on the internet, none of them solved this issue.

    1.I changed the environment variables for in the .bashrc and .bash_profile and sourced it

    export PATH="/usr/local/opt/python@3.9/bin:$PATH"
    export PYTHONPATH="/usr/local/lib/python3.9/site-packages/"



    2.I changed file permission and attributes for site-packages folder

    sudo chmod -R 755 /usr/local/lib/python3.9/site-packages/



    3.I tried uninstall and reinstall Python@3.9 with Homebrew, still won't help

    4.I tried uninstall and reinstall packages with pip3 install --user and Python3 -m pip install --user, still nothing changes.

    Can anyone tell me the solution for this?

    Continue reading...

Compartilhe esta Página