NameError: name 'requests' is not defined ?

Steven D'Aprano steve at
Mon Jul 28 07:07:44 CEST 2014

On Mon, 28 Jul 2014 11:52:03 +0800, 水静流深 wrote:

> there is a simple file ``  saved in
> `D:\Python34\Lib\site-packages`
>  there is only one line in .
>  import requests

Just because mydown has imported requests, doesn't mean it is visible 
everywhere. Each module is a separate namespace, so that 

    requests = "something"

inside module A doesn't break 

    import requests

inside module B.

Inside mydown you import requests, but you still need to import it in the 
interactive interpreter too. Don't worry, the second import will be very 
fast, once a module is imported once the second and subsequent times is 
very quick.


More information about the Python-list mailing list