Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using pip on Windows installed with both python 2.7 and 3.5

I am using Windows 10. Currently, I have Python 2.7 installed. I would like to install Python 3.5 as well. However, if I have both 2.7 and 3.5 installed, when I run pip, how do I get the direct the package to be installed to the desired Python version?

like image 938
guagay_wk Avatar asked Oct 04 '16 11:10

guagay_wk


People also ask

Can you have Python 2 and 3 at the same time?

you can install both python 2 and python 3 in your machine but you can not use both in single code editor in same time. To use both at same time you have to open one IDEs with python 2 and another IDEs with python 3. Yes you can . But, you need to set different environment variables for each of the version.

Does Python 2.7 support pip?

If you're using Python 2.7. 9 (or greater), 3.4 (or greater), then PIP is already built into the Python installer. When you download the latest release, you should remember that a particular release isn't supported indefinitely. According to Python's development cycle, support for Python 3.4 ended in March 2019.


2 Answers

You will have to use the absolute path of pip.

E.g: if I installed python 3 to C:\python35, I would use: C:\> python35\Scripts\pip.exe install packagename

Or if you're on linux, use pip3 install packagename

If you don't specify a full path, it will use whichever pip is in your path.

like image 160
Farhan.K Avatar answered Sep 28 '22 21:09

Farhan.K


Because usually i change my intepreter to run something(i got 2 diff projects with both 2 and 3), i use these solution:

  1. Add path to the environment as usual (of course)
  2. Rename ur python.exe , in my case i want to run python 3 using command python3 on my cmd. So i renamed my python.exe in python3.x directory with python3. Itll works with python 2 ofc.
  3. Then to use pip in both python, i use this command.

python3 -m pip install 'somepackage'

and to run pip on python2

python -m pip install 'somepackage'

This is may not the best solution out there, but i like this one

** WINDOWS **

ref : https://datascience.com.co/how-to-install-python-2-7-and-3-6-in-windows-10-add-python-path-281e7eae62a

like image 31
Akbar Noto Avatar answered Sep 28 '22 22:09

Akbar Noto