gpt4 book ai didi

python - 如何在Python 3中导入 "gleam"包?

转载 作者:太空宇宙 更新时间:2023-11-03 21:35:19 24 4
gpt4 key购买 nike

我正在尝试在Python 3中导入“gleam”包。我已经成功安装了“gleam”包,但仍然显示错误。

from wtforms import fields
from ggplot import *

from gleam import Page, panels

class ScatterInput(panels.Inputs):
title = fields.StringField(label="Title of plot:")
yvar = fields.SelectField(label="Y axis",
choices=[("beef", "Beef"),
("pork", "Pork")])
smoother = fields.BooleanField(label="Smoothing Curve")

class ScatterPlot(panels.Plot):
name = "Scatter"

def plot(self, inputs):
p = ggplot(meat, aes(x='date', y=inputs.yvar))
if inputs.smoother:
p = p + stat_smooth(color="blue")
p = p + geom_point() + ggtitle(inputs.title)
return p

class ScatterPage(Page):
input = ScatterInput()
output = ScatterPlot()

ScatterPage.run()

Error:

ModuleNotFoundError - Traceback (most> recent call last) in ()

----> 1 import gleam

C:\pythonNJ\lib\site-packages\gleam__init__.py in ()

  5 import os
6 import json

----> 7 import urlparse

  8 from collections import namedtuple
9

ModuleNotFoundError: No module named 'urlparse'

我寻找解决方案,发现 urlparse 已移至 python 3 中的新模块,可以将其导入为

from urllib.parse import urlparse

我什至导入了它,但当我尝试导入“gleam”包时,它仍然显示模块“urlparse”的错误。你能建议我如何绕过它(绕过 import urlparse 语句并在 Python 3 中导入 gleam 包)。我知道如何导入 urlparse,但不知道如何导入 gleam 包。

最佳答案

你有两种可能性:

  1. 按照您在 gleam 包中所述自行修改源代码,但可能无法正常工作。
  2. 回退到它所工作的 python 版本 - 所以看起来是 2.7,因为您提到的修改是使用 python 3.0 版本完成的。文档 here 中有说明.

关于python - 如何在Python 3中导入 "gleam"包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53274965/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com