问题描述
- 安装
pip
,virtualenv
和distribute
?
在我的答案中. com/questions/4314376/python-egg-file> SO问题4314376 ,我建议使用ez_setup
,这样您就可以如下安装pip
和virtualenv
了:
In my answer to SO question 4314376, I recommended using ez_setup
so that you could then install pip
and virtualenv
as follows:
curl -O http://peak.telecommunity.com/dist/ez_setup.py
sudo python ez_setup.py
sudo easy_install pip
sudo pip install virtualenv
我最初是从Jesse Noller的博客文章您要在Mac上使用Python吗?.我喜欢保持干净的全局site-packages目录的想法,因此我安装的唯一其他软件包是> c6> 和 distribute
. (由于 distribute
.pixane.com/pip_distribute.png"rel =" noreferrer>此Python公共服务公告.要安装这两个软件包,我使用了:
I originally pulled these instructions from Jesse Noller's blog post So you want to use Python on the Mac?. I like the idea of keeping a clean global site-packages directory, so the only other packages I install there are virtualenvwrapper
and distribute
. (I recently added distribute
to my toolbox because of this Python public service announcement. To install these two packages, I used:
sudo pip install virtualenvwrapper
curl -O http://python-distribute.org/distribute_setup.py
sudo python distribute_setup.py
没有更多的设置工具和easy_install
要真正遵循该Python公共服务声明,请在全新安装Python时做以下:
No more setuptools and easy_install
To really follow that Python public service announcement, on a fresh Python install, I would do the following:
curl -O http://python-distribute.org/distribute_setup.py
sudo python distribute_setup.py
sudo easy_install pip
sudo pip install virtualenv
sudo pip install virtualenvwrapper
雕文的斥责
在对我的答案的评论中/stackoverflow.com/questions/4314376/python-egg-file">SO问题4314376 ,SO用户字形声明:
Glyph's Rebuke
In a comment to my answer to SO question 4314376, SO user Glyph stated:
回到简短的问题
所以字形的响应使我想到了最初的问题:
Back to the short question
So Glyph's response leads me to my original question:
- 安装
pip
,virtualenv
和distribute
?
推荐答案
您可以执行此操作,而无需在Python本身中安装任何内容.
You can do this without installing anything into python itself.
您不需要sudo或任何特权.
You don't need sudo or any privileges.
您不需要编辑任何文件.
You don't need to edit any files.
将virtualenv安装到引导虚拟环境中.使用该虚拟环境创建更多内容.由于virtualenv附带了pip并进行分发,因此您一次安装即可获得所有内容.
Install virtualenv into a bootstrap virtual environment. Use the that virtual environment to create more. Since virtualenv ships with pip and distribute, you get everything from one install.
- 下载virtualenv:
- Download virtualenv:
- http://pypi.python.org/pypi/virtualenv
- https://pypi.python.org/packages/source/v/virtualenv/virtualenv-12.0.7.tar.gz(or whatever is the latest version!)
以下是bash中的一个示例:
Here is an example in bash:
# Select current version of virtualenv:
VERSION=12.0.7
# Name your first "bootstrap" environment:
INITIAL_ENV=bootstrap
# Set to whatever python interpreter you want for your first environment:
PYTHON=$(which python)
URL_BASE=https://pypi.python.org/packages/source/v/virtualenv
# --- Real work starts here ---
curl -O $URL_BASE/virtualenv-$VERSION.tar.gz
tar xzf virtualenv-$VERSION.tar.gz
# Create the first "bootstrap" environment.
$PYTHON virtualenv-$VERSION/virtualenv.py $INITIAL_ENV
# Don't need this anymore.
rm -rf virtualenv-$VERSION
# Install virtualenv into the environment.
$INITIAL_ENV/bin/pip install virtualenv-$VERSION.tar.gz
现在,您可以使用引导"环境创建更多内容:
Now you can use your "bootstrap" environment to create more:
# Create a second environment from the first:
$INITIAL_ENV/bin/virtualenv py-env1
# Create more:
$INITIAL_ENV/bin/virtualenv py-env2
发疯!
这假设您没有使用过旧的virtualenv版本.旧版本需要标记--no-site-packges
(并取决于Python版本--distribute
).现在,您可以仅使用python virtualenv.py path-to-bootstrap
或python3 virtualenv.py path-to-bootstrap
创建引导环境.
This assumes you are not using a really old version of virtualenv.Old versions required the flags --no-site-packges
(and depending on the version of Python, --distribute
). Now you can create your bootstrap environment with just python virtualenv.py path-to-bootstrap
or python3 virtualenv.py path-to-bootstrap
.
这篇关于为Python安装pip,virtualenv和分发的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!