Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PIP3 associated with the wrong python version

Tags:

python

macos

pip

I am aware that this kind of question has been asked many times. I even found out this almost identical issue: How to use pip3 for python 3.6 instead of python 3.5? But I still yet get my problem solved. I am using os x.

I have three versions of pythons: 2.7, 3.6 and 3.7.

python --version
Python 2.7.10

python3 --version
Python 3.7.4

but if I do

pip3 --version
pip 9.0.1 from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (python 3.6)

I do not know why pip3 is pointed to 3.6 not 3.7 (while python3 gives me 3.7)

if I do

python3 
import site; site.getsitepackages()

I have

['/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages']

PIP3 pointed to python 3.6 instead of 3.7. How do I make it point to python 3.7?

I try add python3 to the path but to no avail. I do not want to uninstall python 3.6.

like image 893
Frostless Avatar asked Jun 25 '26 02:06

Frostless


2 Answers

Make a habit of using the following;

python -m pip install <package>

and you will be sure to have the package attached with the right version of python

Eg:-

$ python3 -m pip install requests
like image 142
han solo Avatar answered Jun 27 '26 16:06

han solo


$ which pip3
/usr/bin/pip3 

$ nano /usr/bin/pip3

At first line of the file, you should see

#!/usr/bin/python3

Just change it to the python version you want.

#!/usr/bin/python3.7
or
#!/usr/bin/python3.8

Save it. Done!

like image 26
Coco Golden Avatar answered Jun 27 '26 15:06

Coco Golden



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!