About prompted Chinese word segmentation tool python pip install third-party libraries jieba "ImportError: can not import name 'Random'" error problem

In particular the following error message:

>>> import jieba
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\王益夫\AppData\Local\Programs\Python\Python36-32\lib\site-packages\jieba\__init__.py", line 11, in <module>
    import tempfile
  File "C:\Users\王益夫\AppData\Local\Programs\Python\Python36-32\lib\tempfile.py", line 45, in <module>
    from random import Random as _Random
ImportError: cannot import name 'Random'

 Later found that when I switched to the python installation directory C drive, the normal import jieba library, but the error will be in my personal directory, so wonder if file exists resulting in an error.

The results showed that: there is indeed a random file, resulting file name conflicts.

Thus, when the python reference to third-party libraries, is to start with your current directory to find the corresponding library files, and then go python address lookup.

After the modified files into the corresponding random.py other names, jieba normal library introduced.

Warning: file names named, can not use the library itself or function names, plus the best descriptive words and differences in case.

Guess you like

Origin www.cnblogs.com/wyf-349/p/11341617.html