'ImportError: No module named qrcode, even though i have the module installed

i've been wanting to expand my python skills and thought that making a QR code generator would be fun, however when i try to run the program it gives me this error:

    File "heck.py", line 1, in <module>
    import qrcode
ImportError: No module named qrcode

so i tried reinstalling the module with pip but it gave me this:

Requirement already satisfied: qrcode in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (7.3.1)

my code looks like this:

import qrcode
data = "Buy Dogecoin"
gen = qrcode.make(data)
gen.save('/Users/myname/Desktop/QRcodes/BuyDoge.png')

edit: i was using a different version of pip and python, i just reinstalled qrcode module with pip instead of pip3, then installed the image module



Solution 1:[1]

Regular installation with pip install .... might not work.

Try with

sudo pip install qrcode

or

sudo pip3 install qrcode

Based on the version you use.

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 Anandh G