为特定的Python安装制作pip安装软件包 [英] Make pip install package for specific Python installation

查看:171
本文介绍了为特定的Python安装制作pip安装软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个Python 2.7版本.

I have two versions of Python 2.7.

使用pip-2.7 install bsddb3似乎为本地OS X版本的Python安装了bsddb3.

Using pip-2.7 install bsddb3 seems to install bsddb3 for the native OS X version of Python.

如何将其更改为位于

/Library/Frameworks/Python.framework/Versions/7.3/Resources/Python.app/Contents/MacOS

(用>>> os.path.dirname(sys.executable)找到了可能不正确的路径.* nix仍然使我感到困惑.)

(Found the path with >>> os.path.dirname(sys.executable) which might not be correct. *nix still confuses me.)

注意:这并非重复.其他qs询问如何针对特定的版本(例如2.7与2.6)进行安装.

Note AFAICS this is not a duplicate. The other qs asks how to install for specific versions (e.g. 2.7 vs 2.6).

推荐答案

首先,使用virtualenv -p PYTHON_EXE VIRTUALENV_DIR之类的东西创建一个指向所需python的virtualenv.然后使用source VIRTUALENV_DIR/bin/activate激活该virtualenv,然后运行pip将被隔离,并使用该virtualenv的python.

First, create a virtualenv pointing at the python you want, using something like virtualenv -p PYTHON_EXE VIRTUALENV_DIR. Then activate that virtualenv with source VIRTUALENV_DIR/bin/activate and then running pip will be isolated and use the python of that virtualenv.

如果您不使用virtualenv,请开始:)

If you don't use virtualenv, start :)

这篇关于为特定的Python安装制作pip安装软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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