Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
519 views
in Technique[技术] by (71.8m points)

python - How to change pip installation path

I am using Mac. My pip installation path is /Library/Python/2.7/site-packages. How do I change it to ~/anaconda/lib/python2.7/site-packages/?

Oftentimes, the package installed by pip won't be found by my jupyter notebook and that's why I want to change the path.

I appreciate your help. Other solutions for correctly installing packages are welcome.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can tell pip where to install the package. Use the -t flag , that means the target directory where you want to install the package. Have have look at pip install --help

-t, --target <dir>        Install packages into <dir>. By default this will not replace existing
                          files/folders in <dir>. Use --upgrade to replace existing packages in <dir> with
                          new versions.

You can change this on permanent basis by changing the pip.ini configuration file. See this for detail: pip install path

On Unix and Mac OS X the configuration file is:

$HOME/.pip/pip.conf

On Windows, the configuration file is: %HOME%pippip.ini The %HOME% is located in

 C:UsersBob on windows assuming your name is Bob

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<username>Desktop

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...