pip installation /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory

后端 未结 19 1151
再見小時候
再見小時候 2020-11-28 19:58

I don\'t know what\'s the deal but I am stuck following some stackoverflow solutions which gets nowhere. Can you please help me on this?

  Monas-MacBook-Pro:         


        
19条回答
  •  被撕碎了的回忆
    2020-11-28 20:29

    I'm guessing you have two python installs, or two pip installs, one of which has been partially removed.

    Why do you use sudo? Ideally you should be able to install and run everything from your user account instead of using root. If you mix root and your local account together you are more likely to run into permissions issues (e.g. see the warning it gives about "parent directory is not owned by the current user").

    What do you get if you run this?

    $ head -n1 /usr/local/bin/pip
    

    This will show you which python binary pip is trying to use. If it's pointing /usr/local/opt/python/bin/python2.7, then try running this:

    $ ls -al /usr/local/opt/python/bin/python2.7
    

    If this says "No such file or directory", then pip is trying to use a python binary that has been removed.

    Next, try this:

    $ which python
    $ which python2.7
    

    To see the path of the python binary that's actually working.

    Since it looks like pip was successfully installed somewhere, it could be that /usr/local/bin/pip is part of an older installation of pip that's higher up on the PATH. To test that, you may try moving the non-functioning pip binary out of the way like this (might require sudo):

    $ mv /usr/local/bin/pip /usr/local/bin/pip.old
    

    Then try running your pip --version command again. Hopefully it picks up the correct version and runs successfully.

提交回复
热议问题