简体   繁体   English

pip 为 python2.7 而不是 python3.4 安装模块

[英]pip installs modules for python2.7 instead of python3.4

I have an Amazon EC2 instance.我有一个 Amazon EC2 实例。 On that was just python 2.7 installed.在那只安装了python 2.7。 So I installed Python3 with the command "sudo yum install python34".所以我用命令“sudo yum install python34”安装了Python3。

Then I tried to install modules with "pip install package".然后我尝试使用“pip install package”安装模块。 The terminal told me, that I can upgrade pip.终端告诉我,我可以升级pip。 So i upgraded pip.所以我升级了pip。 No my instance either find the command pip or pip3.没有我的实例要么找到命令 pip 或 pip3。

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"我用谷歌搜索,发现我必须使用“python -m pip install SomePackage”我安装了一个模块并试图用“python3 script.py”启动我的一个脚本

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.它显示我的模块已经安装但在 python2.7 文件夹中。

So what is the right command to use pip with python3.4 instead of python2.7?那么在python3.4而不是python2.7中使用pip的正确命令是什么?

With all the following commands, I get the information that there is no module named pip or pip3:使用以下所有命令,我得到没有名为 pip 或 pip3 的模块的信息:

  • "python3 -m pip install package" “python3 -m pip 安装包”
  • "python34 -m pip install package" “python34 -m pip 安装包”
  • "python3 -m pip3 install package" “python3 -m pip3 安装包”
  • "python3.4 -m pip install package" “python3.4 -m pip 安装包”
  • "pip install package" “pip安装包”
  • "pip3 install package" (Package already installed in python2.7) “pip3 install package”(python2.7中已经安装的包)
  • "pip3.4 install package" “pip3.4安装包”

您可以通过以下方式强制安装 python3 的软件包:

[sudo] python3 -m pip install [package]
  1. try # pip install --upgrade pip .尝试# pip install --upgrade pip this would upgrade pip8.1.1(for python2.7) to 8.1.2(for python3) or这会将 pip8.1.1(for python2.7) 升级到 8.1.2(for python3) 或
  2. try this https://bootstrap.pypa.io/get-pip.py , it would install pip2 and pip3 as well as setup properly, so this is recommended.试试这个https://bootstrap.pypa.io/get-pip.py ,它会安装 pip2 和 pip3 以及正确设置,所以推荐这样做。

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

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