pycharm ImportError: cannot import name 'Random'

As a beginner of python, the configuration of an interpreter often affects the interest of learning in the future. In the process of starting to learn, I encountered a configuration problem with the interpreter pycharm: ImportError: cannot import name 'Random';

This is because the random library (random) is a module in the standard library, and individuals cannot redefine the file (random.py) with the same name as it. If you created a file called random.py when you were learning, just delete it. Yes, but don't delete the files in the python installation directory.

Often the interpreter configuration path is wrong, obscuring the standard library version, because the working directory is included in the search path of the import statement. Any file that tries to use the standard library will first find the file in your working path and will not search for the standard library file of lib in the python configuration path.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326471188&siteId=291194637