Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name 'unicode' is not defined #49

Open
daliborb20 opened this issue Oct 24, 2020 · 3 comments
Open

Name 'unicode' is not defined #49

daliborb20 opened this issue Oct 24, 2020 · 3 comments

Comments

@daliborb20
Copy link

Traceback (most recent call last):
File "example.py", line 10, in
dl.download_course_by_url('')
File "/home/boogyman/skillshare-downloader/code/downloader.py", line 38, in download_course_by_url
self.download_course_by_class_id(m.group(1))
File "/home/boogyman/skillshare-downloader/code/downloader.py", line 64, in download_course_by_class_id
slugify(teacher_name),
File "/home/boogyman/.local/lib/python3.8/site-packages/slugify.py", line 24, in slugify
unicode(
NameError: name 'unicode' is not defined

@VicVaquero
Copy link

@daliborb20 I got the same error as you. I see that you are using python3 and unicode is not longer supported (or was renamed str, idk). I tried to solve this by changing the slugify.py but without much success. Instead, I ran it on a venv with python2.7. However, I still got a similar error but I was able to fix it by modifying a line in the slugify.py.

def slugify(string):

    """
    Slugify a unicode string.

    Example:

        >>> slugify(u"Héllø Wörld")
        u"hello-world"

    """

    return re.sub(r'[-\s]+', '-',
            unicode(
                re.sub(r'[^\w\s-]', '',
                    unicodedata.normalize('NFKD', unicode(string,  'utf-8'))
                    .encode('ascii', 'ignore'))
                .strip()
                .lower()))

hope this helps :)

@shadow-hunte
Copy link

just download python-slugify-4.0.0 and install it. Newer ones will not work, uninstall any latest version you have already installed

@Helaluzzaman
Copy link

install python-slugify not slugify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants