I downloaded the macosx version 3.6.4 and installed it by clicking the donwn-loaded pkg . 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.
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
mint@mint ~ $ pip3 -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