我现在收到这个错误好几天了。出于 setuptools - demsjon - justpy 兼容性的原因,尝试从 Python3.9.9 降级到 Python3.9.2。我正在尝试将 JavaScript 转换为 Python 字典。这是我想在 Quasar 页面上制作的样条图。
这是代码:
import justpy as jp
chart_def = """
{
chart: {
type: 'spline',
inverted: true
},
title: {
text: 'Atmosphere Temperature by Altitude'
},
subtitle: {
text: 'According to the Standard Atmosphere Model'
},
xAxis: {
reversed: false,
title: {
enabled: true,
text: 'Altitude'
},
labels: {
format: '{value} km'
},
accessibility: {
rangeDescription: 'Range: 0 to 80 km.'
},
maxPadding: 0.05,
showLastLabel: true
},
yAxis: {
title: {
text: 'Temperature'
},
labels: {
format: '{value}°'
},
accessibility: {
rangeDescription: 'Range: -90°C to 20°C.'
},
lineWidth: 2
},
legend: {
enabled: false
},
tooltip: {
headerFormat: '<b>{series.name}</b><br/>',
pointFormat: '{point.x} km: {point.y}°C'
},
plotOptions: {
spline: {
marker: {
enable: false
}
}
},
series: [{
name: 'Temperature',
data: [[0, 15], [10, -50], [20, -56.5], [30, -46.5], [40, -22.1],
[50, -2.5], [60, -27.7], [70, -55.7], [80, -76.5]]
}]
}
"""
def app():
wp = jp.WebPage()
my_chart = jp.HighCharts(
a=wp, classes='m-2 p-2 border', style='width: 600px')
my_chart.options = chart_def
return wp
jp.justpy(app)
我收到一条 huuuuge 回溯消息:
JustPy ready to go on http://127.0.0.1:8000
ERROR: Exception in ASGI application
Traceback (most recent call last):
.....
....
..
AttributeError: 'dict' object has no attribute 'has_key'
ERROR h11_impl: Exception in ASGI application
Traceback (most recent call last):
.....
...
..
AttributeError: 'dict' object has no attribute 'has_key'
ERROR: Exception in ASGI application
Traceback (most recent call last):
...
..
..
AttributeError: 'dict' object has no attribute 'has_key'
ERROR h11_impl: Exception in ASGI application
Traceback (most recent call last):
...
..
..
AttributeError: 'dict' object has no attribute 'has_key'
更新:
我设法克服了这个错误,并且使用 demjson==2.2.4 得到了一个新错误:
Traceback (most recent call last):
File "c:\Users\Fotis Avg\Desktop\Python_course\DataAnalysis3rdApp\test.py", line 1, in <module>
import justpy as jp
File "C:\Users\Fotis Avg\AppData\Local\Programs\Python\Python39\lib\site-packages\justpy\__init__.py", line 1, in <module>
from .justpy import *
File "C:\Users\Fotis Avg\AppData\Local\Programs\Python\Python39\lib\site-packages\justpy\justpy.py", line 13, in <module>
from .chartcomponents import *
File "C:\Users\Fotis Avg\AppData\Local\Programs\Python\Python39\lib\site-packages\justpy\chartcomponents.py", line 2, in <module>
import demjson
File "C:\Users\Fotis Avg\AppData\Local\Programs\Python\Python39\lib\site-packages\demjson.py", line 645
class json_int( (1L).__class__ ): # Have to specify base this way to satisfy 2to3
^
SyntaxError: invalid syntax