如何在Python 3.4中使用pip 3? [英] How do I use pip 3 with Python 3.4?

查看:367
本文介绍了如何在Python 3.4中使用pip 3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的操作系统是 Lubuntu 14.04,默认的Python版本是Python 2.7.6,但是在

My OS is Lubuntu 14.04 and the default Python version is Python 2.7.6, but in

/usr/bin

它说我安装了Python 3.4(当我运行python3 -V时说我安装了Python 3.4.0). Python 3.4是否预装了 pip ?因为当我跑步

it says I have Python 3.4 installed (when I run python3 -V it says I have Python 3.4.0). Does Python 3.4 come with a pre-installed pip? Because when I run

pip -V

在终端上说当前未安装该程序.如此说来,假设我想创建一个使用Python 3.4的 Django 项目. 3:首先下载python3-pip,然后下载virtualenv,然后执行

in a terminal it says that the program is currently not installed. With that said, assume I want to create a Django project which uses Python 3.4.3: do I first download python3-pip and then virtualenv and then do

pip3 install Django==1.8

?还是在我已经安装的Python 3.4中预安装了pip  3?

? or is there a pre-installed pip 3 which comes with Python 3.4 which I already have installed?

推荐答案

而不是通过apt-get或其他方式安装python3-pip(因为回购中的版本太旧),请下载

Instead of installing python3-pip via apt-get or whatever (because the version in the repo is too old), download get-pip.py, switch to the folder where you saved it, and run

sudo python3 get-pip.py

,它将为您安装最新版本的pip.它可能会创建到pip3的符号链接,但可能不会,我不记得了.

and it will install the latest version of pip for you. It may create a symlink to pip3, it may not, I don't remember.

然后您可以运行

sudo pip install virtualenv

然后使用它来创建您的virtualenv,将其激活,然后使用安装在其中的pip来获取Django.

then use it to create your virtualenv, activate it, then use the pip installed inside it to get Django.

注意:

您可以使用相同的get-pip.py副本为Python 2安装pip.但是,如果要执行此操作,建议您运行

You can use the same copy of get-pip.py to install pip for Python 2. If you want to do that, however, I'd advise you to run

sudo python get-pip.py

运行之前

sudo python3 get-pip.py

如果您安装的是 last ,则将使用pip文件名.我不知道Python 2是否安装了名为pip2的命令(我知道可以通过pip升级pip),但是在运行Python 2安装后,运行

Whichever one you install last will take the pip filename. I don't know if Python 2 installs a command called pip2 (I know upgrading pip via pip does), but after you run the Python 2 install, run

sudo ln -s /usr/local/bin/pip2.7 /usr/local/bin/pip2

创建pip2别名.然后,您可以运行Python 3安装,该安装将覆盖/usr/local/bin/pip,然后运行

to create a pip2 alias. You can then run the Python 3 install, which will overwrite /usr/local/bin/pip, then run

sudo ln -s /usr/local/bin/pip3.4 /usr/local/bin/pip3

也可以创建一个pip3命令(如果出现文件已存在的错误,那么就可以了).现在,不必在安装到系统site-packages时运行pip并完全不知道要调用哪个版本,而是可以使用pip2pip3明确声明所需的版本.

to create a pip3 command as well (if you get an error that the file already exists, then you're good to go). Now, instead of running pip when installing to your system site-packages and not knowing exactly which version you're calling, you can just use pip2 and pip3 to explicitly state the version you want.

这篇关于如何在Python 3.4中使用pip 3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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