question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NameError: free variable 'url' referenced before assignment in enclosing scope

See original GitHub issue

I am following the docs, and try this video:

url = "https://www.youtube.com/watch?v=RO014qcVkJc"

yt =pytube.YouTube(url)

   File "C:\Users\Moondra\AppData\Local\Programs\Python\Python36\lib\site-packages\pytube\mixins.py", line 41, in <listcomp>
if any([x in url for x in ['signature=', 'sig=']]):
NameError: free variable 'url' referenced before assignment in enclosing scope

Anyone understand what the problem is ?

I have upgraded to latest official version via pip

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
hbmartincommented, Jan 21, 2020

@moondra2017 fixed in my Python 3 only fork: https://github.com/hbmartin/pytube3

1reaction
moondra2017commented, Jul 5, 2019

could you place your entire code/script here?

Let me see if I can find it.

could you place your entire code/script here?

That’s pretty much the entire script:


import pytube

url = "https://www.youtube.com/watch?v=RO014qcVkJc"

yt =pytube.YouTube(url)

Also:

>>> pytube.__version__
'9.5.1'

Read more comments on GitHub >

github_iconTop Results From Across the Web

NameError: free variable 're' referenced before assignment in ...
"free variable" in the traceback suggests that this is a local variable in an enclosing scope. something like this:
Read more >
free variable 'outer' referenced before assignment in enclosing ...
try: outer except NameError: outer = None if outer is None or outer.done(): if not fut.cancelled(): # Mark exception retrieved. fut.exception() ...
Read more >
free variable 'product' referenced before assignment in ... - Odoo
NameError : free variable 'product' referenced before assignment in enclosing scope | Odoo.
Read more >
"free variable 'type' referenced before assignment in enclosing ...
Coding example for the question NameError: ("free variable 'type' referenced before assignment in enclosing scope"-pandas.
Read more >
#527259 - NameError: free variable 'dialog' referenced before ...
Subject: NameError: free variable 'dialog' referenced before assignment in enclosing scope. Date: Wed, 6 May 2009 14:49:05 +0200.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found