2

I ran my code many times in my computer and didn't get this error. But all of a sudden this came

  File "e:\Python 3.8.0\lib\site-packages\comtypes\client\_code_cache.py", lin
    import ctypes, logging, os, sys, tempfile, types
  File "e:\Python 3.8.0\lib\tempfile.py", line 45, in <module>
    from random import Random as _Random
ImportError: cannot import name 'Random' from 'random' (e:\python codes\random
wjandrea
  • 28,235
  • 9
  • 60
  • 81
Ebinesh. A
  • 43
  • 6
  • 3
    Does this answer your question? [Tweepy: ImportError: cannot import name Random](https://stackoverflow.com/questions/25750961/tweepy-importerror-cannot-import-name-random) – Zoe Nov 18 '20 at 07:58
  • That error message is incomplete. It looks like `.py)` got cut off from the end. – wjandrea Nov 03 '21 at 01:05

1 Answers1

6

You've probably created a file called random.py. Since that is the exact name of a built-in module, your program will get mixed up, and import the file you've created.

To fix this, rename your fie to something like random2.py, and it should work.

Red
  • 26,798
  • 7
  • 36
  • 58