'ModuleNotFoundError - faker import at Jupyter notebook on Mac

I am trying to import faker from jupyter notebook on mac and failed.

It complains as follows:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-6235527da291> in <module>()
----> 1 from faker import Faker

ModuleNotFoundError: No module named 'faker'

I use pip install faker and the system says

Requirement already satisfied: faker in /Applications/anaconda3/lib/python3.6/site-packages
Requirement already satisfied: text-unidecode in /Applications/anaconda3/lib/python3.6/site-packages (from faker)
Requirement already satisfied: python-dateutil>=2.4 in /Applications/anaconda3/lib/python3.6/site-packages (from faker)
Requirement already satisfied: six in /Applications/anaconda3/lib/python3.6/site-packages (from faker)

I would be appreciated if anyone can help me out

Thanks



Solution 1:[1]

  • Solution1: you're using python3.6, so try pip3 instead of pip
  • Solution2: use a python3 virtual env like mentioned in this tuto
  • Solution3: this is another idea from here : use python -m pip install <package> rather than pip install <package>

Solution 2:[2]

Since you are using Python python3.6, use pip3 install Faker instead of pip install Faker.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Akshansh Gusain