barcode image

442 views
Skip to first unread message

gangadhar kadam

unread,
Jul 8, 2013, 4:48:13 AM7/8/13
to erpnext-dev...@googlegroups.com
Hello All,
   I have installed pyBarcode/0.7 using "pip install pyBarcode". I have created a custom doctype for barcode and wrote following code in barcode.py
  import barcode
  from barcode.writer import ImageWriter
  EAN = barcode.get_barcode_class('ean13')
  ean = EAN(u'5901234123457', writer=ImageWriter())
  fullname = ean.save('ean13_kadam')

 but got  following error

File "../app/selling/doctype/barcode/barcode.py", line 11, in on_update
    from barcode.writer import ImageWriter
 ImportError: No module named writer

same code works in python terminal and in ERPNext cgi

how to resolve this issue?


Thank you

Anand Doshi

unread,
Jul 8, 2013, 5:58:25 AM7/8/13
to erpnext-dev...@googlegroups.com
Hi Gangadhar,

When importing modules, python searches the local folder first and then the python path.

In this case, when executing barcode.py, python found that a module named barcode exists in the local folder i.e. app.some_module.doctype.barcode.barcode, and hence, it isn't able to find the barcode module.

You can confirm this by checking dir(barcode) after import barcode

As a workaround, you can write a function - create_barcode_image in, say, erpnext_module_name/utils.py, and use:
from erpnext_module_name.utils import create_barcode_image

-Anand.

--
Please Note:
If you are posting an issue,
1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To post to this group, send email to erpnext-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/97312ef3-64bc-4436-8ea4-aebdf800b4b0%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages