pip 为 python2.7 而不是 python3.4 安装模块 [英] pip installs modules for python2.7 instead of python3.4
问题描述
我有一个 Amazon EC2 实例.在那只安装了python 2.7.所以我用命令sudo yum install python34"安装了Python3.
I have an Amazon EC2 instance. On that was just python 2.7 installed. So I installed Python3 with the command "sudo yum install python34".
然后我尝试使用pip install package"安装模块.终端告诉我,我可以升级pip.所以我升级了pip.没有我的实例要么找到命令 pip 或 pip3.
Then I tried to install modules with "pip install package". The terminal told me, that I can upgrade pip. So i upgraded pip. No my instance either find the command pip or pip3.
我在谷歌上搜索并发现我必须使用python -m pip install SomePackage"我安装了一个模块并尝试使用python3 script.py"启动我的一个脚本
I googled and find that I have to use "python -m pip install SomePackage" I installed a module and tried to start one of my scripts with "python3 script.py"
我得到信息,我的模块仍未安装.我尝试再次安装它.它显示我的模块已经安装但在 python2.7 文件夹中.
I got the information that my module still isn't installed. I tried to install it again. It showed me that my module is already installed but in the python2.7 folder.
那么使用 pip 和 python3.4 而不是 python2.7 的正确命令是什么?
So what is the right command to use pip with python3.4 instead of python2.7?
使用以下所有命令,我得到的信息是没有名为 pip 或 pip3 的模块:
With all the following commands, I get the information that there is no module named pip or pip3:
- "python3 -m pip 安装包"
- "python34 -m pip 安装包"
- "python3 -m pip3 安装包"
- "python3.4 -m pip 安装包"
- pip 安装包"
- pip3 install package"(python2.7中已经安装的包)
- pip3.4 安装包"
推荐答案
- 尝试
# pip install --upgrade pip
.这会将 pip8.1.1(for python2.7) 升级到 8.1.2(for python3) 或 - 试试这个https://bootstrap.pypa.io/get-pip.py,它将安装 pip2 和 pip3 以及正确设置,因此建议这样做.
- try
# pip install --upgrade pip
. this would upgrade pip8.1.1(for python2.7) to 8.1.2(for python3) or - try this https://bootstrap.pypa.io/get-pip.py, it would install pip2 and pip3 as well as setup properly, so this is recommended.
这篇关于pip 为 python2.7 而不是 python3.4 安装模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!