Python pip install module is not found. How to link python to pip location?

后端 未结 10 1319
青春惊慌失措
青春惊慌失措 2020-11-27 15:37

I\'m a newbie and I needed the pySerial and feedparser module for my projects. I\'m running Mountain lion.

I followed the following tutorial so that I could upgrade

10条回答
  •  借酒劲吻你
    2020-11-27 15:56

    If your python and pip binaries are from different versions, modules installed using pip will not be available to python.

    Steps to resolve:

    1. Open up a fresh terminal with a default environment and locate the binaries for pip and python.
    readlink $(which pip)
    ../Cellar/python@2/2.7.15_1/bin/pip
    
    readlink $(which python)
    /usr/local/bin/python3      <-- another symlink
    
    readlink /usr/local/bin/python3
    ../Cellar/python/3.7.2/bin/python3
    

    Here you can see an obvious mismatch between the versions 2.7.15_1 and 3.7.2 in my case.

    1. Replace the pip symlink with the pip binary which matches your current version of python. Use your python version in the following command.
    ln -is /usr/local/Cellar/python/3.7.2/bin/pip3 $(which pip)
    

    The -i flag promts you to overwrite if the target exists.

    That should do the trick.

提交回复
热议问题