Wednesday, February 24, 2016

Running Python pip on a specific python installation

Python versions are a bit confused on my Ubuntu install right now. If I type "python" at the command line I get Python 2.7. If I type python3 then I get Python 3.4. And python3.5 gives me Python 3.5. Not usually a problem because I put the correct entry in the shebang of the script I am running, but it is sometimes difficult to get pip to install in the right place (or, I should say, to figure out where pip installed and determine if it is where I want it, because who knows what the "right" place is?).

So to ensure that something installs in the correct place, instead of typing

pip install paho-mqtt

use

python3.5 -m pip install paho-mqtt

and it will install in the specific Python version you indicated (in this case, python3.5).

No comments:

Post a Comment