pippython-3.7

How to fix ModuleNotFoundError: No module named 'pyjokes'


I have installed pyjokes with pip3!

sudo pip3 install pyjokes

And have it in the terminal when i do pip3 list below picture!

enter image description here

And i have my simple file down below here!

import pyjokes

joke = pyjokes.get_joke('english','neutral')
print(joke)

But i get this error when i run the file pic below![enter image description here]2

How can i fix this error?


Solution

  • I searched on my own and saw this helped me You import sys to your file and use sys.path.append() for adding the file name to your file it worked strange with pyjokes.get_joke() though?

    import sys
    
    sys.path.append('/usr/local/lib/python3.7/dist-packages/')
    
    import pyjokes
    
    print(pyjokes.get_joke())