Upload file error: UnicodeEncodeError: 'ascii' codec can't encode characters in position 58-64

113 views
Skip to first unread message

Y Y

unread,
Sep 16, 2014, 10:46:18 PM9/16/14
to erpnext-dev...@googlegroups.com
As subject. if file name is local language. Please suggest how to fix.

Traceback (innermost last):
File "/home/erpnext/frappe-bench/apps/frappe/frappe/handler.py", line 47, in uploadfile
ret = frappe.utils.file_manager.upload()
File "/home/erpnext/frappe-bench/apps/frappe/frappe/utils/file_manager.py", line 33, in upload
filedata = save_uploaded(dt, dn)
File "/home/erpnext/frappe-bench/apps/frappe/frappe/utils/file_manager.py", line 52, in save_uploaded
return save_file(fname, content, dt, dn);
File "/home/erpnext/frappe-bench/apps/frappe/frappe/utils/file_manager.py", line 118, in save_file
fname = get_file_name(fname, content_hash[-6:])
File "/home/erpnext/frappe-bench/apps/frappe/frappe/utils/file_manager.py", line 254, in get_file_name
if len(n_records) > 0 or os.path.exists(get_files_path(fname)):
File "/home/erpnext/frappe-bench/env/lib/python2.7/genericpath.py", line 18, in exists
os.stat(path)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 58-64: ordinal not in range(128)

Pratik Vyas

unread,
Sep 17, 2014, 2:50:05 AM9/17/14
to erpnext-dev...@googlegroups.com
Seems like a bug. Please post the file name.
> --
> Note:
>
> If you are posting an issue,
>
> 1. ERPNext is a free and open source software and support is given on this
> forum by a team (https://frappe.io/webnotes). So please consider donating if
> you find this forum useful (https://frappe.io/buy). Even a small amount
> would be helpful.
> 2. 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.
> 3. Paste your code at http://pastebin.com or http://gist.github.com and send
> only the URL via email
> 4. 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.
>
> End of Note
> ---
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/erpnext-developer-forum/235fedf5-e614-4e62-b3d8-c8fd3893249e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Pratik
erpnext

Y Y

unread,
Sep 17, 2014, 3:34:07 AM9/17/14
to erpnext-dev...@googlegroups.com
新东方名师推荐BEC词汇.doc

above is the file name, it is local file name in chinese.


在 2014年9月17日星期三UTC+8上午10时46分18秒,Y Y写道:

Rushabh Mehta

unread,
Sep 18, 2014, 12:48:28 AM9/18/14
to erpnext-dev...@googlegroups.com
That file name works for me too....

I am running Python 2.7.5

@Pratik any clue?



@rushabh_mehta

-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. 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.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. 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.
 
End of Note
--- 
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.

Pratik Vyas

unread,
Sep 18, 2014, 1:14:42 AM9/18/14
to erpnext-dev...@googlegroups.com

Y Y

unread,
Sep 18, 2014, 1:31:31 AM9/18/14
to erpnext-dev...@googlegroups.com
mine is 2.7.3, maybe it's time to re-setup from scratch. will update. thanks.

在 2014年9月18日星期四UTC+8下午1时14分42秒,Pratik Vyas写道:
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/erpnext-developer-forum/079433d5-896c-4dde-9a1b-fee98883da9b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> Note:
>
> If you are posting an issue,
>
> 1. ERPNext is a free and open source software and support is given on this
> forum by a team (https://frappe.io/webnotes). So please consider donating if
> you find this forum useful (https://frappe.io/buy). Even a small amount
> would be helpful.
> 2. 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.
> 3. Paste your code at http://pastebin.com or http://gist.github.com and send
> only the URL via email
> 4. 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.
>
> End of Note
> ---
> 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

Pratik Vyas

unread,
Sep 18, 2014, 5:50:52 AM9/18/14
to erpnext-dev...@googlegroups.com
File "/home/erpnext/frappe-bench/apps/frappe/frappe/utils/file_manager.py",
line 254, in get_file_name
if len(n_records) > 0 or os.path.exists(get_files_path(fname))

Can you try changing that line to

if len(n_records) > 0 or os.path.exists(get_files_path(fname.encode('utf-8')))
>> > email to erpnext-developer...@googlegroups.com.
>> > email to erpnext-developer...@googlegroups.com.
> --
> Note:
>
> If you are posting an issue,
>
> 1. ERPNext is a free and open source software and support is given on this
> forum by a team (https://frappe.io/webnotes). So please consider donating if
> you find this forum useful (https://frappe.io/buy). Even a small amount
> would be helpful.
> 2. 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.
> 3. Paste your code at http://pastebin.com or http://gist.github.com and send
> only the URL via email
> 4. 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.
>
> End of Note
> ---
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/erpnext-developer-forum/d38ada52-728f-4d97-afef-0de5217719c5%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Pratik
erpnext

Pratik Vyas

unread,
Sep 18, 2014, 5:54:29 AM9/18/14
to erpnext-dev...@googlegroups.com
Sorry, I meant whatever Anand is saying here,
https://github.com/frappe/frappe/issues/847#issuecomment-55999093
--
Pratik
erpnext

Y Y

unread,
Sep 18, 2014, 6:33:45 AM9/18/14
to erpnext-dev...@googlegroups.com
Tried, not work at my side, anyway, i think we will setup from scratch and try. Thanks very much.

在 2014年9月18日星期四UTC+8下午5时54分29秒,Pratik Vyas写道:

Y Y

unread,
Sep 18, 2014, 6:37:47 AM9/18/14
to erpnext-dev...@googlegroups.com
Tried, not work at my side, anyway, i think we will setup from scratch and try. Thanks very much.

在 2014年9月18日星期四UTC+8下午5时54分29秒,Pratik Vyas写道:
Sorry, I meant whatever Anand is saying here,

Y Y

unread,
Sep 22, 2014, 4:49:56 AM9/22/14
to erpnext-dev...@googlegroups.com
Dear Team,

In my VM, i enter into python console, then show sys.getdefaultencoding(), result is: ascii

I think that's the issue. why would happens to that, i used same installation setup(via bench).

any simple solution for this?

Thanks,
Yang

在 2014年9月17日星期三UTC+8上午10时46分18秒,Y Y写道:

Anand Doshi

unread,
Sep 22, 2014, 9:37:01 AM9/22/14
to erpnext-dev...@googlegroups.com
It is supposed to be ascii by default and it should still work like in my system. Is your bench folder name or some other folder in hierarchy contain non English names?

-Anand 
--
1. Please be kind and don't send large attachments
2. For issues, features requests use https://github.com/frappe/erpnext/issues

---
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 view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/27829800-d656-44c3-91d5-23345d9a8d97%40googlegroups.com.

Y Y

unread,
Sep 22, 2014, 10:31:42 AM9/22/14
to erpnext-dev...@googlegroups.com
I fixed that..., It shall be get_files_path(fname).encode('utf-8') haha...

在 2014年9月22日星期一UTC+8下午9时37分01秒,Anand Doshi写道:
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+unsub...@googlegroups.com.

Anand Doshi

unread,
Sep 22, 2014, 11:15:32 AM9/22/14
to erpnext-dev...@googlegroups.com
Pull request please 😀

Sent from my phone
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/f75736ad-8652-4e1f-aed9-b5e6f31d89de%40googlegroups.com.

Y Y

unread,
Sep 22, 2014, 8:30:12 PM9/22/14
to erpnext-dev...@googlegroups.com
Against 4 or 5?

在 2014年9月22日星期一UTC+8下午11时15分32秒,Anand Doshi写道:

Rushabh Mehta

unread,
Sep 22, 2014, 11:39:38 PM9/22/14
to erpnext-dev...@googlegroups.com
4 is okay for this.

@rushabh_mehta
via mobile
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/298f1bb8-693b-43a8-a95f-4d48fbb0b114%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages