2

I am using Anaconda Python 3.4 on a Windows 7 PC now. Recently I am trying to follow the instruction of the book High Performance Python to learn some profiling skills. To this end I need to use pip install to install several tools. Unfortunately, not all of them support Python 3, and I have to install Python 2.7 now.

Before installing Python 2.7, I would like to know how I should handle with such 2.7/3.4 coexisting system? How do I setup pip so that I could use pip install to install packages for different Python versions separately?

bastelflp
  • 9,362
  • 7
  • 32
  • 67
Sidney
  • 321
  • 1
  • 2
  • 13

2 Answers2

2

You can create a conda environment via:

conda create --name py27 python=2.7

and use this environment for your work with Python 2.7. Activate it with the command activate py27, going back to your root environment is just activate.

In the py27 environment you can install pip and all other packages you need.

bastelflp
  • 9,362
  • 7
  • 32
  • 67
2

pip is generally located at the Python27\Scripts and/or Python34\Scripts folder. If you wish to invoke pip directly in the command line, these folders should be in your PATH environment variable.

Now I would just rename pip.exe in Python34\Scripts into any other name, for example pip_for_3.exe. That way, when I install packages for Python27, I would just use:

pip install <package name>

and packages for Python34:

pip_for_3 install <package name>

Coexisting Python installations are not a problem, you just have to know which version is invoked every time. See this answer for the same idea.

Community
  • 1
  • 1
jowabels
  • 122
  • 1
  • 9