Joey Joestar
Joey Joestar

Reputation: 235

How to default my python to another python version

I am having a big headache dealing with python versions. I couldn't do pip install xlwt because it was complaining to me about SSL certification problem. So then I installed python 2.7.16 and installed xlwt and got Requirement already satisfied: xlwt in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (1.3.0)

However then when I run python code.py I keep getting ImportError: No module named xlwt although I just did pip install xlwt

what should I do?

Upvotes: 0

Views: 32

Answers (1)

Kris
Kris

Reputation: 23569

The safest way to make sure your pip refers to the correct python version is to call it explicitly from the python version you intend to use, e.g.

/usr/bin/python2.7 -m pip install some-package

If it complains that the pip module is missing, you can install it via:

wget https://bootstrap.pypa.io/get-pip.py
/usr/bin/python2.7 get-pip.py

You can replace /usr/bin/python2.7 with whatever version you want to use.

Upvotes: 1

Related Questions