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
Python's ImportError ( ModuleNotFoundError ) indicates that you tried to import a module that Python doesn't find. It can usually be eliminated by adding a file named __init__.py to the directory and then adding this directory to $PYTHONPATH .
In Python, ImportError occurs when the Python program tries to import module which does not exist in the private table. This exception can be avoided using exception handling using try and except blocks. We also saw examples of how the ImportError occurs and how it is handled.
This is caused by the fact that the version of Python you're running your script with is not configured to search for modules where you've installed them. This happens when you use the wrong installation of pip to install packages.
The __init__.py files are required to make Python treat directories containing the file as packages. This prevents directories with a common name, such as string , unintentionally hiding valid modules that occur later on the module search path.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With