It is strange to encounter a problem recently in writing a Python script: The python script is perfectly normal, but the total error "Attributeerror: ' Module ' object has no attribute ' xxx '". This is actually a problem with the. pyc file.
Problem Locator:
View the source file of the import library, discover that the source file exists without errors, and that the. pyc file exists for the source file
Problem Solving methods:
1. When naming the Py script, do not match the python reserved word, module name, etc.
2. Delete the. pyc file for the library (because the. pyc file is generated by the PY script each time it is run; If the code is not updated, the runtime will still walk PYc when the. pyc file is generated, so delete the. pyc file), rerun the code, or find an environment where you can run the code, and copy the. pyc file to replace the
Python script error Attributeerror: ' Module ' object has no attribute ' xxx ' workaround