如何更改pip安装到的默认目录? [英] How do I change the default directory that pip installs to?

查看:649
本文介绍了如何更改pip安装到的默认目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行命令时

pip install virtualenv

我得到:

Installing virtualenv script to /usr/local/share/python

但是我的默认virtualenv在另一个位置:

But my default virtualenv is in a different place:

which virtualenv
usr/local/bin/virtualenv

我希望pip默认安装到usr/local/bin目录.任何帮助将不胜感激.

I'd like pip to install to the usr/local/bin directory by default. Any help would be greatly appreciated.

推荐答案

如果您要手动确定软件包的驻留位置,则可以始终使用以下命令将源代码分发下载到您选择的目录中:

If you want to manually decide where you want packages to reside, you could always download the source distribution to a directory of your choice with the following:

pip install -d <path_to_my_directory>

但是,当您安装时,我认为您可能希望将可执行控制台脚本(如程序包的setup.py文件中所定义;例如virtualenv)定义在$ PATH环境变量中包含的目录中.

But when you install, I think you probably want to put the executable console scripts (as defined in the package's setup.py file; like virtualenv for example) in a directory included in your $PATH environmental variable.

您可以通过执行以下操作手动指定:

You can specify this manually by doing the following:

sudo python setup.py install --install-scripts /usr/bin/

sudo python setup.py install --install-scripts /usr/local/bin/

如果您还有其他问题,请告诉我...

Let me know if you have any other questions...

这篇关于如何更改pip安装到的默认目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆