Python Forum
Python installation change on Mac
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python installation change on Mac
#1
Sometime last year, I installed Python 3.x on my MacBook, using the installer from Python.org, and when I typed which python3, bash would return usr/local/bin/python3.

Today I reinstalled Python 3.6.4 on the same MacBook, also using the installer from Python.org. When I typed which python3, bash now returns /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.

This contradicts the tutorial here:

https://docs.python.org/3/tutorial/interpreter.html

I have been searching for an answer and cannot find one. Why the change? Moreover, I do not know how to replace the Python 3.6.0 that is still residing in usr/local/bin/python3, and searching the docs at Python.org has given me nothing.

Note, I am not using Homebrew because I teach Python to non-computer science students, and I'd like them to do a straight install from the installer at Python.org - which is what I did.

I am seeking help specifically about the current Mac installer from Python.org.

I just used this script to completely remove every trace of Python 3, all versions, from my MacBook:

https://github.com/csev/uninstall-python3

It worked great. (Does not touch virtualenvs.) Then I reinstalled from the Python.org installer.

But I am still stuck with /Library/Frameworks/Python.framework/Versions/3.6/bin/python3 as the location of Python 3.
Sad
Reply
#2
Doing it Right
Quote:python3 will launch the homebrew-installed Python 3 interpreter.
Homebrew version of Python 3 is installed then pip will point to Python 3.
gmeyers Wrote:However when I run a simple script that worked with 2.7 it fails importing import matplotlib and numpy with "ModuleNotFoundError" error. What else is necessary for the install to find the packages.
You most pip install into Python 3.
Check that pip or pip3 point to python 3.
mint@mint ~ $ pip -V

# Install
pip install numpy
pip install -U matplotlib

Alternative pyenv is the best version management to use,
and safe it do not mess with system Python installation.
Examle Linux,work the same on Mac.
# Install
mint@mint ~ $ pyenv install 3.6.4
Downloading Python-3.6.4.tar.xz...
-> https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
Installing Python-3.6.4...
Installed Python-3.6.4 to /home/mint/.pyenv/versions/3.6.4

# Set python and pip to point to 3.6.4
mint@mint ~ $ pyenv global 3.6.4
mint@mint ~ $ python -V
Python 3.6.4
mint@mint ~ $ pip -V
pip 9.0.1 from /home/mint/.pyenv/versions/3.6.4/lib/python3.6/site-packages (python 3.6)
# Finish
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Preparing an Installation with Python JgKSuperstar 2 2,609 Nov-30-2021, 11:40 AM
Last Post: JgKSuperstar
  Software(Python) Installation. Navigate Refactor Run Tools VCS tab rgbrolly 3 2,558 Oct-19-2019, 08:09 PM
Last Post: buran
  Python package installation issue. msomasun 3 3,204 Oct-09-2018, 03:56 PM
Last Post: msomasun

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020