pip installs packages successfully, but executables not found from command line

后端 未结 9 2489
感情败类
感情败类 2020-12-07 13:44

I am working on mac OS X Yosemite, version 10.10.3.

I installed python2.7 and pip using macport as done in http://johnlaudun.org/20150512-installing-and-setting-pip

9条回答
  •  北荒
    北荒 (楼主)
    2020-12-07 14:14

    Solution

    Based on other answers, for linux and mac you can run the following:

    echo "export PATH=\"`python3 -m site --user-base`/bin:$PATH\"" >> ~/.bashrc
    source ~/.bashrc
    

    instead of python3 you can use any other link to python version: python, python2.7, python3.6, python3.9, etc.

    Explanation

    In order to know where the user packages are installed in the current OS (win, mac, linux), we run:

    python3 -m site --user-base
    

    We know that the scripts go to the bin/ folder where the packages are installed.

    So we concatenate the paths:

    echo `python3 -m site --user-base`/bin
    

    Then we export that to an environment variable.

    export PATH=\"`python3 -m site --user-base`/bin:$PATH\"
    

    Finally, in order to avoid repeating the export command we add it to our .bashrc file and we run source to run the new changes, giving us the suggested solution mentioned at the beginning.

提交回复
热议问题