英文:
UnicodeEncodeError: 'charmap' codec can't encode character '\u03a3' in position 409: character maps to <undefined>
问题
我正在运行Python代码从JIRA中提取问题。这段代码由Atlassian提供,他们使用JiraOne库。
在Config.Json文件中,我们有以下信息。
{
"user": "prince@example.com",
"password": "<APITOKEN_HERE>",
"url": "https://nexusfive.atlassian.net"
}
以下是我正在运行的Python代码。
from jiraone import LOGIN, issue_export
import json
file = "config.json"
config = json.load(open(file))
LOGIN(**config)
jql = "project in (AB, BC, IT, IP) order by created DESC"
issue_export(jql=jql)
我收到以下错误消息,但不知道如何解决。
错误消息:
下载以CSV格式导出的问题。
<Response [200]> OK ::正在下载页面 0 的 9 个问题
Traceback (most recent call last):
File "C:\Users\User123\Desktop\PBI Files\Python Scripts\untitled10.py", line 12, in <module>
issue_export(jql=jql)
File "C:\Users\User123\Anaconda3\lib\site-packages\jiraone\reporting.py", line 2189, in export_issues
file_writer(
File "C:\Users\User123\Anaconda3\lib\site-packages\jiraone\reporting.py", line 3223, in file_writer
f.write(content)
File "C:\Users\User123\Anaconda3\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' 编解码器无法在位置 409 编码字符 'Σ':字符映射到 <undefined>
英文:
I am running Python code to pull the issues from JIRA. This code is provided by Atlassian and they are using JiraOne Library.
In the Config.Json file we have the following information.
{
"user": "prince@example.com",
"password": "<APITOKEN_HERE>",
"url": "https://nexusfive.atlassian.net"
}
Below is the Python code I am running.
from jiraone import LOGIN, issue_export
import json
file = "config.json"
config = json.load(open(file))
LOGIN(**config)
jql = "project in (AB, BC, IT, IP) order by created DESC"
issue_export(jql=jql)
I am getting below error message and no clue on how to resolve this.
ERROR MESSAGE:
Downloading issue export in CSV format.
<Response [200]> OK ::downloading issues at page: 0 of 9
Traceback (most recent call last):
File "C:\Users\User123\Desktop\PBI Files\Python Scripts\untitled10.py", line 12, in <module>
issue_export(jql=jql)
File "C:\Users\User123\Anaconda3\lib\site-packages\jiraone\reporting.py", line 2189, in export_issues
file_writer(
File "C:\Users\User123\Anaconda3\lib\site-packages\jiraone\reporting.py", line 3223, in file_writer
f.write(content)
File "C:\Users\User123\Anaconda3\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u03a3' in position 409: character maps to <undefined>
答案1
得分: 0
按照Prince Nyeche提供的修复方法,您需要执行以下步骤。在文本编辑器中打开文件C:\Users\User123\Anaconda3\lib\site-packages\jiraone\reporting.py
。转到第2189行。它应该是这样的:
file_writer(
folder,
file_name,
content=issues.content.decode(encoding, errors=errors),
mark="file",
mode="w+",
)
添加建议的编辑:
content=issues.content.decode('utf-8', errors="replace"),
保存文件。然后再次尝试运行您的untitled10.py
代码。
英文:
To follow the fix provided by Prince Nyeche you have to do the following. Open the file C:\Users\User123\Anaconda3\lib\site-packages\jiraone\reporting.py
in your text editor. Go to line 2189. It should look like this:
file_writer(
folder,
file_name,
content=issues.content.decode(encoding, errors=errors),
mark="file",
mode="w+",
)
Add the suggested edit:
content=issues.content.decode('utf-8', errors="replace"),
Save your file. Then try your untitled10.py
code again.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论