Question

I am receiving the following error when importing Process in python 3.3. Is there any reason I would get such an error, or is this a bug? I am running the django server in another terminal window, but I doubt that would have anything to do with this.

Python 3.3.2 (default, Nov  8 2013, 13:38:57) 
[GCC 4.8.2 20131017 (Red Hat 4.8.2-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
# extension module loaded from '/usr/lib64/python3.3/lib-dynload/readline.cpython-33m.so'
import 'readline' # <_frozen_importlib.ExtensionFileLoader object at 0x7f8a00fc1050>
>>> from multiprocessing import Process
# ./__pycache__/multiprocessing.cpython-33.pyc matches ./multiprocessing.py
# code object from ./__pycache__/multiprocessing.cpython-33.pyc
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 1567, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1534, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1024, in load_module
  File "<frozen importlib._bootstrap>", line 1005, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 870, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "./multiprocessing.py", line 1, in <module>
    from multiprocessing import Process
ImportError: cannot import name Process
Was it helpful?

Solution

The line File "./multiprocessing.py" in your traceback suggests that you have a file named multiprocessing.py in the working directory.

Try removing/renaming it, because it shadows the real multiprocessing module. The problem here is that the very first entry in your sys.path is always '', so a file in the working dir will be preferred to a standard module when doing an import.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top