dimanche 13 octobre 2019

ImportError: cannot import name, even though I've every solution here

My file is named "foo.py". It has only two lines.

import random
print(random.randint(10))

The error is...

    Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 45, in <module>
    from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
  File "math.py", line 2, in <module>
    from random import randint
ImportError: cannot import name randint
  1. I am one MacOS 10.14.6
  2. I note that I did not call random.randint() in this script, even though it showed up in the error text.
  3. I ran the script with $python
  4. My /usr/bin/python is linked to python 2.7
  5. I've tried this with python 3 as well, with the same error.

I've tried deleting random.pyc




Aucun commentaire:

Enregistrer un commentaire