如何更改pip的默认安装位置 [英] How to change default install location for pip

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

问题描述

我正在尝试使用pip安装Pandas,但遇到了一些麻烦.我只运行了sudo pip install pandas成功下载了熊猫.但是,它没有下载到我想要的位置.这是我使用pip show pandas时看到的内容:

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, it did not get downloaded to the location that I wanted. Here's what I see when I use pip show pandas:

---
Name: pandas
Version: 0.14.0
Location: /Library/Python/2.7/site-packages/pandas-0.14.0-py2.7-macosx-10.9-intel.egg
Requires: python-dateutil, pytz, numpy

因此已安装.但是当我创建一个新的Python项目并在System Libs/lib/python下搜索熊猫时,我感到困惑,因为它没有出现.但是,我过去下载的其他一些软件包的确出现了,所以我尝试看看它们在哪里.运行pip show numpy(我可以毫无问题地导入)产生:

So it is installed. But I was confused when I created a new Python Project and searched under System Libs/lib/python for pandas, because it didn't show up. Some of the other packages that I've downloaded in the past did show up, however, so I tried to take a look at where those were. Running pip show numpy (which I can import with no problem) yielded:

---
Name: numpy
Version: 1.6.2
Location: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Requires: 

在完全不同的目录中.为了确认我的错误,我运行了pip install pyquery来查看将其下载到何处,并得到:

Which is in a completely different directory. For the sake of confirming my error, I ran pip install pyquery to see where it would be downloaded to, and got:

Name: pyquery
Version: 1.2.8
Location: /Library/Python/2.7/site-packages
Requires: lxml, cssselect

所以和熊猫在同一地方...

So the same place as pandas...

如何更改pip的默认下载位置,以便将这些软件包下载到numpy所在的相同位置?

How do I change the default download location for pip so that these packages are downloaded to the same location that numpy is in?

注意:在寻找解决方案时,我遇到了一些类似的问题,但没有看到永久更改默认位置的任何内容.

Note: There were a few similar questions that I saw when searching for a solution, but I didn't see anything that mentioned permanently changing the default location.

推荐答案

根据

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

您将需要在 pip.ini 文件中指定默认安装位置,根据上面的网站,该文件通常也位于以下位置

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

在Unix和Mac OS X上,配置文件为:$ HOME/.pip/pip.conf

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

在Windows上,配置文件为:%HOME%\ pip \ pip.ini

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

%HOME%位于Windows 上的C:\Users\Bob(假定),您的名字是 Bob

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

在Linux上,可以使用cd ~

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

找到pip目录时,可能必须创建pip.ini文件.然后,您需要在pip.inipip.config内放入(假设在Windows上)类似

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

除了用所需的任何路径替换C:\Users\Bob\Desktop.如果您使用的是 Linux ,则可以将其替换为/usr/local/your/path

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

保存命令后将是

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.

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

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