Python import unittest Error

1, Python version is: Python 3.12.3
2, Windows version is: Windows 10 Pro 64-bit operating system, x64-based processor

3, Question:

when run import unittest, it will return below error message:
1, Copy()
{‘上海’, ‘北京’, ‘广州’}

2, Shallow Copy
Traceback (most recent call last):
File “”, line 1, in
File “D:\Program Files\Python\Lib\”, line 61, in
from .case import (addModuleCleanup, TestCase, FunctionTestCase, SkipTest, skip,
File “D:\Program Files\Python\Lib\unittest\”, line 6, in
import pprint
File “D:\Program Files\Python\Lib\”, line 38, in
import dataclasses as _dataclasses
File “D:\Program Files\Python\Lib\”, line 3, in
import copy
File “C:\Users\Administrator\Desktop\Python Works\”, line 18, in
new_list = copy.copy(original_list)
TypeError: ‘module’ object is not callable

4, tried solution:
I had successfully run this command before, but it always return error recently.
I had uninstalled the Python software and installed a latest version of Python, but it return same error.
I had checked the lib file, there is unittest file in it.

please support to find out the reason and how to solve this issue.

thanks in advance.



Don’t name your file, that causes clashes with the stdlib module copy.



High appreciation for your help, You are right, solved.

To make tracebacks easier to read, format as if code, between ``` lines.

1 Like

Thanks for your reply. solved