Error python "No module named Image"

Hi all

I’m trying to make python code to add QRcode to drawings.
I have some error at this moment.
can anybody help me.

btw I added some library to lib folder. seems some of them works but some not.
I have this PIL folder with is image.py is inside it but still python can not find it.

import rhinoscriptsyntax as rs
import qrcode

input_data = "test"


qr = qrcode.QRCode(
    version=1,
    box_size=10,
    border=5)
qr.add_data(input_data)
qr.make(fit=True)
img = qr.make_image(fill='black', back_color='white')
img.save('D:\\Downloads\\barcode0000.jpg')

path = "D:\\Downloads\\barcode0000.jpg"
cmd = "-Picture " + path
rs.Command(cmd, True)

It could be that those Python modules aren’t supported by IronPython. In which case you might consider implementing .NET instead. Here’s a basic example of implementing the System.Drawing namespace to save a bitmap:

thanks but I’m not expert to do so at the moment.
is there a way to make QR or Barcode by python in Rhino?

In that case, maybe just try getting the qrcode Python module working:

The first step here is to ensure that the version you’re implementing is compatible with Python 2.7 (meaning download an older version, check the release notes to ensure compatibility). Next figure out which dependencies qrcode has (look through the documentation or the source code) and ensure they too are Python 2.7 compatible. If it’s still not working, figure out if it’s actually a pure Python module (i.e. and not using numpy or something else that won’t work in IronPython).

If you’re just looking to generate QR codes, I’m pretty certain you’ll find examples of this in Grasshopper, either here or on the old forum that might work for you.

Edit: You can also consider the new native CPython support offered by Hops. Which might negate the compatibility issues entirely.

2 Likes

Check this topic

2 Likes

I just solve my issue through online api from another website.
I think it is hard to do it in Rhino python

Hello,

We managed to get this working well in both Grasshopper and Rhino in the thread @anon39580149 linked above but if you are happy with your solution then stick with it :smiley:

Graham

3 Likes