1

I'm tyring to import the "gleam" package in Python 3. I have installed the "gleam" package successfully, but still it showing error.

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'

I looked for the solution and I found that urlparse has been moved to a new module in python 3, which can be imported as

from urllib.parse import urlparse

And I even imported it, but still when I trying to import "gleam" package it shows error of module "urlparse". Can you suggest me how to bypass it (bypassing import urlparse statement and importing gleam package in Python 3). I know how to import the urlparse but I don't know how to import the gleam package.

petezurich
  • 9,280
  • 9
  • 43
  • 57
David
  • 366
  • 3
  • 22

2 Answers2

0

You have two possiblities:

  1. Modify source code yourself as you stated inside gleam package, but it could work incorrectly.
  2. Fall back to version of python it works on - so 2.7 it seems, since the modification you mentioned was done with python 3.0 release. It's stated in docs here.
Shan
  • 369
  • 2
  • 9
0

Just do this to get over it:

from:

import urlparser

to:

import urllib.parse
Hunting
  • 51
  • 1
  • 3