How to change default install location for pip

前端 未结 3 1817
天涯浪人
天涯浪人 2020-11-28 05:41

I\'m trying to install Pandas using pip, but I\'m having a bit of trouble. I just ran sudo pip install pandas which successfully downloaded pandas. However, i

相关标签:
3条回答
  • 2020-11-28 06:14

    According to pip documentation at

    http://pip.readthedocs.org/en/stable/user_guide/#configuration

    You will need to specify the default install location within a pip.ini file, which, also according to the website above is usually located as follows

    On Unix and Mac OS X the configuration file is: $HOME/.pip/pip.conf

    On Windows, the configuration file is: %HOME%\pip\pip.ini

    The %HOME% is located in C:\Users\Bob on windows assuming your name is Bob

    On linux the $HOME directory can be located by using cd ~

    You may have to create the pip.ini file when you find your pip directory. Within your pip.ini or pip.config you will then need to put (assuming your on windows) something like

    [global]
    target=C:\Users\Bob\Desktop
    

    Except that you would replace C:\Users\Bob\Desktop with whatever path you desire. If you are on Linux you would replace it with something like /usr/local/your/path

    After saving the command would then be

    pip install pandas
    

    However, the program you install might assume it will be installed in a certain directory and might not work as a result of being installed elsewhere.

    0 讨论(0)
  • 2020-11-28 06:19

    You can set the following environment variable:

    PIP_TARGET=/path/to/pip/dir
    

    https://pip.pypa.io/en/stable/user_guide/#environment-variables

    0 讨论(0)
  • 2020-11-28 06:36

    Open Terminal and type:

    pip config set global.target /Users/Bob/Library/Python/3.8/lib/python/site-packages
    

    except instead of

    /Users/Bob/Library/Python/3.8/lib/python/site-packages
    

    you would use whatever directory you want.

    0 讨论(0)
提交回复
热议问题