user3373322 user3373322 - 1 year ago 130
Python Question

Python 3.5: I am getting an error: "NameError: name 'multiprocessing' is not defined"

I am getting an error:

pool = multiprocessing.Pool(5)
NameError: name 'multiprocessing' is not defined

So, how to fix it ? Thank you very much :)

from multiprocessing import Pool
from selenium.common.exceptions import TimeoutException
from bs4 import BeautifulSoup
from selenium import webdriver

if __name__ == '__main__':
driver = webdriver.Firefox()

pool = multiprocessing.Pool(5), uid_list)

Answer Source

You haven't declared what multiprocessing is. You haven't imported the module either, you just imported Pool from multiprocessing. In other words, multiprocessing is not in your namespace, hence NameError. Try import the whole module and it should work.

import multiprocessing

Otherwise, since you imported Pool, you could just write:

pool = Pool(5)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download