简体   繁体   English

更改pip安装软件包的目录

[英]Changing directory where pip installs packages

I have a python2.6 installed on Oracle linux. 我在Oracle Linux上安装了python2.6。 I decided to use a newer python version and installed python 2.7.13. 我决定使用较新的python版本并安装了python 2.7.13。

I have also installed pip to manage packages. 我还安装了pip来管理软件包。

Now if I use pip to install a package it still installs it to the old location: /usr/lib/python2.6/site-packages 现在,如果我使用pip安装软件包,它仍会将其安装到旧位置:/usr/lib/python2.6/site-packages

Is there a way to force pip to install packages for the newer python 2.7 version? 有没有办法强制pip为较新的python 2.7版本安装软件包?

Posable Repeat Post 可能的重复帖子

"Use a version of pip installed against the Python instance you want to install new packages to. “使用要安装新包的Python实例安装的pip版本。

In many distributions, there may be separate python2.6-pip and python2.7-pip packages, invoked with binary names such as pip-2.6 and pip-2.7. 在许多发行版中,可能会有单独的python2.6-pip和python2.7-pip软件包,使用二进制名称(例如pip-2.6和pip-2.7)来调用。 If pip is not packaged in your distribution for the desired target, you might look for a setuptools or easyinstall package, or use virtualenv (which will always include pip in a generated environment). 如果未将pip打包在所需目标的发行版中,则可能会寻找setuptools或easyinstall软件包,或使用virtualenv(在生成的环境中始终包含pip)。

pip's website includes installation instructions, if you can't find anything within your distribution." ~Charles Duffy 如果您在发行版中找不到任何内容,请在pip的网站上提供安装说明。”〜Charles Duffy

Taken from How to install a module use pip for specific version of? 取自如何使用特定版本的pip安装模块?

Did you check Install a Python package into a different directory using pip? 您是否选中了使用pip将Python软件包安装到其他目​​录中? .

To install in specified target directory use "pip install --target= " 要在指定的目标目录中安装,请使用“ pip install --target =“

Oracle Linux uses the system-installed version of Python for almost all of its command-line utilities, so changing that could irreparably damage your system. Oracle Linux几乎所有的命令行实用程序都使用系统安装的Python版本,因此进行更改可能会不可避免地损坏您的系统。

Instead of replacing the default Python install, you should strongly consider using Python 2.7 from Software Collections instead. 与其替换默认的Python安装,不如强烈考虑使用Software Collections中的Python 2.7

Using Software Collections means that the install of Python 2.7 is separated from the system install, so you don't run the risk of damaging your system. 使用Software Collections意味着Python 2.7的安装与系统安装是分开的,因此不会冒损坏系统的风险。 You can then make it available to your applications via the scl tool. 然后,您可以通过scl工具将其提供给您的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM