问题
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:
- 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.
回答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