0

I have a problem with importing numpy for python3, I'm new in coding and followed all steps. I want to import numpy in python3 but not in python2 which is set by defaultn my mac mojave 10.14.2.

I have Python 2.7.10 by default on my mac and can switch now to Python 3.7.2 in shell. I installed pip 18.1 as described in PyPA and now I can import numpy only in Python 2. what should I do to be able to import numpy in Python 3? Is it better to set Python 3 by default on my mac mojave 10.14.2?

1
  • You probably want to read up on what virtualenvs are. Commented Jan 21, 2019 at 19:18

3 Answers 3

3

You can install numpy in python3 with help of pip3 command instead of pip. Yes you should change python3 as default as python2 support is going to end this year.

Sign up to request clarification or add additional context in comments.

Comments

1

You should read about Python environments. This will allows you to works with specific Python version and dependences separeted by project. Now days it is almost a must for all Pythonysts.

https://realpython.com/python-virtual-environments-a-primer/

Comments

0

pip is for python 2, pip3 is for python 3

Start by updating the package list using the following command:

sudo apt update

Use the following command to install pip for Python 3:

sudo apt install python3-pip

Once the installation is complete, verify the installation by checking the pip version:

pip3 --version

Then install numpy using pip3

pip3 install numpy

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.