简体   繁体   English

使用virtualenv安装pip3

[英]Installing pip3 with a virtualenv

I am trying to clean up a few things now that I have Mavericks. 我现在正试图清理一些事情,因为我有小牛队。 I used Homebrew to install python 2.7 and 3.3. 我使用Homebrew来安装python 2.7和3.3。 I also have their respective pips. 我也有各自的点子。 Now I want to have a sane virtualenv setup. 现在我希望有一个理智的virtualenv设置。

I see from virtualenv with python2 and python3 via Homebrew that I can specify which version of python a newly-created virtualenv will use. 我从virtualenv看到python2和python3通过Homebrew我可以指定新创建的virtualenv将使用哪个版本的python。 What is the best (ie, easiest to use/remember) way to make sure that a virtualenv using Python 3.3 uses pip3? 什么是最好的(即,最容易使用/记住)方式来确保使用Python 3.3的virtualenv使用pip3?

ETA: I've not had to use 3.3 before, so this is my first experience trying to maintain different versions. ETA:我以前不必使用3.3,所以这是我尝试维护不同版本的第一次体验。 Sorry if this has an obvious answer. 对不起,如果这有明显的答案。

Credit goes to scythargon for this one (left in a comment to Kristof 's answer in this thread ) and, since it did exactly what I needed, I figured it deserved its own answer. 归功于scythargon (留在Kristof 在这个帖子中回答的评论),因为它完全符合我的要求,我认为它应该得到自己的答案。

When creating a virtualenv with virtualenvwrapper use the -p flag to explicitly associate it with a specific version of Python. 使用virtualenvwrapper创建virtualenv时,请使用-p标志将其与特定版本的Python显式关联。 In the examples below replace {virtualenv_name} with your intended virtual environment name: 在下面的示例中,将{virtualenv_name}替换为您想要的虚拟环境名称:

Python 3.3: Python 3.3:

$ mkvirtualenv {virtualenv_name} -ppython3.3

Python 3.4: Python 3.4:

$ mkvirtualenv {virtualenv_name} -ppython3.4

Python 2.7: Python 2.7:

$ mkvirtualenv {virtualenv_name} -ppython2.7

Have a look at this article: Python Development Environment on Mac OS X Mavericks 10.9 . 看一下这篇文章: Mac OS X Mavericks 10.9上的Python开发环境 It describes quite clearly how to set up both versions of Python on the same machine using Homebrew and contains some helpful pointers. 它非常清楚地描述了如何使用Homebrew在同一台机器上设置两个版本的Python,并包含一些有用的指针。

In the article, the author appends -py3 to a Python3 virtualenv, as @moliware already suggested. 在文章中,作者将@py3附加到Python3 virtualenv,正如@moliware已经建议的那样。

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

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