pip installs modules for python2.7 instead of python3.4

拟墨画扇 提交于 2021-01-28 04:40:12

问题


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".

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.

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"

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.

So what is the right command to use pip with python3.4 instead of python2.7?

With all the following commands, I get the information that there is no module named pip or pip3:

  • "python3 -m pip install package"
  • "python34 -m pip install package"
  • "python3 -m pip3 install package"
  • "python3.4 -m pip install package"
  • "pip install package"
  • "pip3 install package" (Package already installed in python2.7)
  • "pip3.4 install package"

回答1:


  1. try # pip install --upgrade pip. this would upgrade pip8.1.1(for python2.7) to 8.1.2(for python3) or
  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.



回答2:


You can force package install for python3 by:

[sudo] python3 -m pip install [package]


来源:https://stackoverflow.com/questions/37479175/pip-installs-modules-for-python2-7-instead-of-python3-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!