Saturday, October 23, 2021

[SOLVED] Install python package (e.g. lxml) to specific python version (e.g. 3.1) when another python package (e.g 2.6) is default

Issue

It bugs me theese simple things:

I notice that my installed lxml can't be found from my python3.1 shell.

There is no problem in python2.6 shell

So my question now is - how can I install lxml to python3.1? sudo pip install lxml just tells me that lxml is already installed.

I know I could properbly use virtualenv to do this - but quite honestely I am just trying to learn python in the most simple manner posible. I therefore don't think I need "package lockdown" the way I (mis)understands virtualenv provides. Anything that can keep the confusion at bay and let me focus on the programming :-)

I could of course just uninstall python2.6 but I guess all hell would break loose on my debian box then.

Thanks in advance


Solution

Each version of Python is independent of the others. This goes for everything including pip commands. You need to install pip once per each version, and you then get one pip command per version.

For a longer explanation, see my blog post on the topic.



Answered By - Lennart Regebro